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.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.expando.model.ExpandoValue;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing ExpandoValue in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ExpandoValue
036     * @generated
037     */
038    @ProviderType
039    public class ExpandoValueCacheModel implements CacheModel<ExpandoValue>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ExpandoValueCacheModel)) {
048                            return false;
049                    }
050    
051                    ExpandoValueCacheModel expandoValueCacheModel = (ExpandoValueCacheModel)obj;
052    
053                    if (valueId == expandoValueCacheModel.valueId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, valueId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(17);
068    
069                    sb.append("{valueId=");
070                    sb.append(valueId);
071                    sb.append(", companyId=");
072                    sb.append(companyId);
073                    sb.append(", tableId=");
074                    sb.append(tableId);
075                    sb.append(", columnId=");
076                    sb.append(columnId);
077                    sb.append(", rowId=");
078                    sb.append(rowId);
079                    sb.append(", classNameId=");
080                    sb.append(classNameId);
081                    sb.append(", classPK=");
082                    sb.append(classPK);
083                    sb.append(", data=");
084                    sb.append(data);
085                    sb.append("}");
086    
087                    return sb.toString();
088            }
089    
090            @Override
091            public ExpandoValue toEntityModel() {
092                    ExpandoValueImpl expandoValueImpl = new ExpandoValueImpl();
093    
094                    expandoValueImpl.setValueId(valueId);
095                    expandoValueImpl.setCompanyId(companyId);
096                    expandoValueImpl.setTableId(tableId);
097                    expandoValueImpl.setColumnId(columnId);
098                    expandoValueImpl.setRowId(rowId);
099                    expandoValueImpl.setClassNameId(classNameId);
100                    expandoValueImpl.setClassPK(classPK);
101    
102                    if (data == null) {
103                            expandoValueImpl.setData(StringPool.BLANK);
104                    }
105                    else {
106                            expandoValueImpl.setData(data);
107                    }
108    
109                    expandoValueImpl.resetOriginalValues();
110    
111                    return expandoValueImpl;
112            }
113    
114            @Override
115            public void readExternal(ObjectInput objectInput) throws IOException {
116                    valueId = objectInput.readLong();
117                    companyId = objectInput.readLong();
118                    tableId = objectInput.readLong();
119                    columnId = objectInput.readLong();
120                    rowId = objectInput.readLong();
121                    classNameId = objectInput.readLong();
122                    classPK = objectInput.readLong();
123                    data = objectInput.readUTF();
124            }
125    
126            @Override
127            public void writeExternal(ObjectOutput objectOutput)
128                    throws IOException {
129                    objectOutput.writeLong(valueId);
130                    objectOutput.writeLong(companyId);
131                    objectOutput.writeLong(tableId);
132                    objectOutput.writeLong(columnId);
133                    objectOutput.writeLong(rowId);
134                    objectOutput.writeLong(classNameId);
135                    objectOutput.writeLong(classPK);
136    
137                    if (data == null) {
138                            objectOutput.writeUTF(StringPool.BLANK);
139                    }
140                    else {
141                            objectOutput.writeUTF(data);
142                    }
143            }
144    
145            public long valueId;
146            public long companyId;
147            public long tableId;
148            public long columnId;
149            public long rowId;
150            public long classNameId;
151            public long classPK;
152            public String data;
153    }