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.portal.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    import com.liferay.portal.model.MVCCModel;
024    import com.liferay.portal.model.PortletPreferences;
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 PortletPreferences in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see PortletPreferences
036     * @generated
037     */
038    @ProviderType
039    public class PortletPreferencesCacheModel implements CacheModel<PortletPreferences>,
040            Externalizable, MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof PortletPreferencesCacheModel)) {
048                            return false;
049                    }
050    
051                    PortletPreferencesCacheModel portletPreferencesCacheModel = (PortletPreferencesCacheModel)obj;
052    
053                    if ((portletPreferencesId == portletPreferencesCacheModel.portletPreferencesId) &&
054                                    (mvccVersion == portletPreferencesCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, portletPreferencesId);
064    
065                    return HashUtil.hash(hashCode, mvccVersion);
066            }
067    
068            @Override
069            public long getMvccVersion() {
070                    return mvccVersion;
071            }
072    
073            @Override
074            public void setMvccVersion(long mvccVersion) {
075                    this.mvccVersion = mvccVersion;
076            }
077    
078            @Override
079            public String toString() {
080                    StringBundler sb = new StringBundler(15);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", portletPreferencesId=");
085                    sb.append(portletPreferencesId);
086                    sb.append(", ownerId=");
087                    sb.append(ownerId);
088                    sb.append(", ownerType=");
089                    sb.append(ownerType);
090                    sb.append(", plid=");
091                    sb.append(plid);
092                    sb.append(", portletId=");
093                    sb.append(portletId);
094                    sb.append(", preferences=");
095                    sb.append(preferences);
096                    sb.append("}");
097    
098                    return sb.toString();
099            }
100    
101            @Override
102            public PortletPreferences toEntityModel() {
103                    PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
104    
105                    portletPreferencesImpl.setMvccVersion(mvccVersion);
106                    portletPreferencesImpl.setPortletPreferencesId(portletPreferencesId);
107                    portletPreferencesImpl.setOwnerId(ownerId);
108                    portletPreferencesImpl.setOwnerType(ownerType);
109                    portletPreferencesImpl.setPlid(plid);
110    
111                    if (portletId == null) {
112                            portletPreferencesImpl.setPortletId(StringPool.BLANK);
113                    }
114                    else {
115                            portletPreferencesImpl.setPortletId(portletId);
116                    }
117    
118                    if (preferences == null) {
119                            portletPreferencesImpl.setPreferences(StringPool.BLANK);
120                    }
121                    else {
122                            portletPreferencesImpl.setPreferences(preferences);
123                    }
124    
125                    portletPreferencesImpl.resetOriginalValues();
126    
127                    return portletPreferencesImpl;
128            }
129    
130            @Override
131            public void readExternal(ObjectInput objectInput) throws IOException {
132                    mvccVersion = objectInput.readLong();
133                    portletPreferencesId = objectInput.readLong();
134                    ownerId = objectInput.readLong();
135                    ownerType = objectInput.readInt();
136                    plid = objectInput.readLong();
137                    portletId = objectInput.readUTF();
138                    preferences = objectInput.readUTF();
139            }
140    
141            @Override
142            public void writeExternal(ObjectOutput objectOutput)
143                    throws IOException {
144                    objectOutput.writeLong(mvccVersion);
145                    objectOutput.writeLong(portletPreferencesId);
146                    objectOutput.writeLong(ownerId);
147                    objectOutput.writeInt(ownerType);
148                    objectOutput.writeLong(plid);
149    
150                    if (portletId == null) {
151                            objectOutput.writeUTF(StringPool.BLANK);
152                    }
153                    else {
154                            objectOutput.writeUTF(portletId);
155                    }
156    
157                    if (preferences == null) {
158                            objectOutput.writeUTF(StringPool.BLANK);
159                    }
160                    else {
161                            objectOutput.writeUTF(preferences);
162                    }
163            }
164    
165            public long mvccVersion;
166            public long portletPreferencesId;
167            public long ownerId;
168            public int ownerType;
169            public long plid;
170            public String portletId;
171            public String preferences;
172    }