001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.expando.kernel.model.ExpandoRow;
020    
021    import com.liferay.portal.kernel.model.CacheModel;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing ExpandoRow in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see ExpandoRow
037     * @generated
038     */
039    @ProviderType
040    public class ExpandoRowCacheModel implements CacheModel<ExpandoRow>,
041            Externalizable {
042            @Override
043            public boolean equals(Object obj) {
044                    if (this == obj) {
045                            return true;
046                    }
047    
048                    if (!(obj instanceof ExpandoRowCacheModel)) {
049                            return false;
050                    }
051    
052                    ExpandoRowCacheModel expandoRowCacheModel = (ExpandoRowCacheModel)obj;
053    
054                    if (rowId == expandoRowCacheModel.rowId) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    return HashUtil.hash(0, rowId);
064            }
065    
066            @Override
067            public String toString() {
068                    StringBundler sb = new StringBundler(11);
069    
070                    sb.append("{rowId=");
071                    sb.append(rowId);
072                    sb.append(", companyId=");
073                    sb.append(companyId);
074                    sb.append(", modifiedDate=");
075                    sb.append(modifiedDate);
076                    sb.append(", tableId=");
077                    sb.append(tableId);
078                    sb.append(", classPK=");
079                    sb.append(classPK);
080                    sb.append("}");
081    
082                    return sb.toString();
083            }
084    
085            @Override
086            public ExpandoRow toEntityModel() {
087                    ExpandoRowImpl expandoRowImpl = new ExpandoRowImpl();
088    
089                    expandoRowImpl.setRowId(rowId);
090                    expandoRowImpl.setCompanyId(companyId);
091    
092                    if (modifiedDate == Long.MIN_VALUE) {
093                            expandoRowImpl.setModifiedDate(null);
094                    }
095                    else {
096                            expandoRowImpl.setModifiedDate(new Date(modifiedDate));
097                    }
098    
099                    expandoRowImpl.setTableId(tableId);
100                    expandoRowImpl.setClassPK(classPK);
101    
102                    expandoRowImpl.resetOriginalValues();
103    
104                    return expandoRowImpl;
105            }
106    
107            @Override
108            public void readExternal(ObjectInput objectInput) throws IOException {
109                    rowId = objectInput.readLong();
110    
111                    companyId = objectInput.readLong();
112                    modifiedDate = objectInput.readLong();
113    
114                    tableId = objectInput.readLong();
115    
116                    classPK = objectInput.readLong();
117            }
118    
119            @Override
120            public void writeExternal(ObjectOutput objectOutput)
121                    throws IOException {
122                    objectOutput.writeLong(rowId);
123    
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(modifiedDate);
126    
127                    objectOutput.writeLong(tableId);
128    
129                    objectOutput.writeLong(classPK);
130            }
131    
132            public long rowId;
133            public long companyId;
134            public long modifiedDate;
135            public long tableId;
136            public long classPK;
137    }