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.model.CacheModel;
020    import com.liferay.portal.kernel.model.MVCCModel;
021    import com.liferay.portal.kernel.model.PortalPreferences;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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 PortalPreferences in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see PortalPreferences
036     * @generated
037     */
038    @ProviderType
039    public class PortalPreferencesCacheModel implements CacheModel<PortalPreferences>,
040            Externalizable, MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof PortalPreferencesCacheModel)) {
048                            return false;
049                    }
050    
051                    PortalPreferencesCacheModel portalPreferencesCacheModel = (PortalPreferencesCacheModel)obj;
052    
053                    if ((portalPreferencesId == portalPreferencesCacheModel.portalPreferencesId) &&
054                                    (mvccVersion == portalPreferencesCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, portalPreferencesId);
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(11);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", portalPreferencesId=");
085                    sb.append(portalPreferencesId);
086                    sb.append(", ownerId=");
087                    sb.append(ownerId);
088                    sb.append(", ownerType=");
089                    sb.append(ownerType);
090                    sb.append(", preferences=");
091                    sb.append(preferences);
092                    sb.append("}");
093    
094                    return sb.toString();
095            }
096    
097            @Override
098            public PortalPreferences toEntityModel() {
099                    PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
100    
101                    portalPreferencesImpl.setMvccVersion(mvccVersion);
102                    portalPreferencesImpl.setPortalPreferencesId(portalPreferencesId);
103                    portalPreferencesImpl.setOwnerId(ownerId);
104                    portalPreferencesImpl.setOwnerType(ownerType);
105    
106                    if (preferences == null) {
107                            portalPreferencesImpl.setPreferences(StringPool.BLANK);
108                    }
109                    else {
110                            portalPreferencesImpl.setPreferences(preferences);
111                    }
112    
113                    portalPreferencesImpl.resetOriginalValues();
114    
115                    return portalPreferencesImpl;
116            }
117    
118            @Override
119            public void readExternal(ObjectInput objectInput) throws IOException {
120                    mvccVersion = objectInput.readLong();
121    
122                    portalPreferencesId = objectInput.readLong();
123    
124                    ownerId = objectInput.readLong();
125    
126                    ownerType = objectInput.readInt();
127                    preferences = objectInput.readUTF();
128            }
129    
130            @Override
131            public void writeExternal(ObjectOutput objectOutput)
132                    throws IOException {
133                    objectOutput.writeLong(mvccVersion);
134    
135                    objectOutput.writeLong(portalPreferencesId);
136    
137                    objectOutput.writeLong(ownerId);
138    
139                    objectOutput.writeInt(ownerType);
140    
141                    if (preferences == null) {
142                            objectOutput.writeUTF(StringPool.BLANK);
143                    }
144                    else {
145                            objectOutput.writeUTF(preferences);
146                    }
147            }
148    
149            public long mvccVersion;
150            public long portalPreferencesId;
151            public long ownerId;
152            public int ownerType;
153            public String preferences;
154    }