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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.MVCCModel;
023    import com.liferay.portal.model.PortalPreferences;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    /**
031     * The cache model class for representing PortalPreferences in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see PortalPreferences
035     * @generated
036     */
037    @ProviderType
038    public class PortalPreferencesCacheModel implements CacheModel<PortalPreferences>,
039            Externalizable, MVCCModel {
040            @Override
041            public long getMvccVersion() {
042                    return mvccVersion;
043            }
044    
045            @Override
046            public void setMvccVersion(long mvccVersion) {
047                    this.mvccVersion = mvccVersion;
048            }
049    
050            @Override
051            public String toString() {
052                    StringBundler sb = new StringBundler(11);
053    
054                    sb.append("{mvccVersion=");
055                    sb.append(mvccVersion);
056                    sb.append(", portalPreferencesId=");
057                    sb.append(portalPreferencesId);
058                    sb.append(", ownerId=");
059                    sb.append(ownerId);
060                    sb.append(", ownerType=");
061                    sb.append(ownerType);
062                    sb.append(", preferences=");
063                    sb.append(preferences);
064                    sb.append("}");
065    
066                    return sb.toString();
067            }
068    
069            @Override
070            public PortalPreferences toEntityModel() {
071                    PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
072    
073                    portalPreferencesImpl.setMvccVersion(mvccVersion);
074                    portalPreferencesImpl.setPortalPreferencesId(portalPreferencesId);
075                    portalPreferencesImpl.setOwnerId(ownerId);
076                    portalPreferencesImpl.setOwnerType(ownerType);
077    
078                    if (preferences == null) {
079                            portalPreferencesImpl.setPreferences(StringPool.BLANK);
080                    }
081                    else {
082                            portalPreferencesImpl.setPreferences(preferences);
083                    }
084    
085                    portalPreferencesImpl.resetOriginalValues();
086    
087                    return portalPreferencesImpl;
088            }
089    
090            @Override
091            public void readExternal(ObjectInput objectInput) throws IOException {
092                    mvccVersion = objectInput.readLong();
093                    portalPreferencesId = objectInput.readLong();
094                    ownerId = objectInput.readLong();
095                    ownerType = objectInput.readInt();
096                    preferences = objectInput.readUTF();
097            }
098    
099            @Override
100            public void writeExternal(ObjectOutput objectOutput)
101                    throws IOException {
102                    objectOutput.writeLong(mvccVersion);
103                    objectOutput.writeLong(portalPreferencesId);
104                    objectOutput.writeLong(ownerId);
105                    objectOutput.writeInt(ownerType);
106    
107                    if (preferences == null) {
108                            objectOutput.writeUTF(StringPool.BLANK);
109                    }
110                    else {
111                            objectOutput.writeUTF(preferences);
112                    }
113            }
114    
115            public long mvccVersion;
116            public long portalPreferencesId;
117            public long ownerId;
118            public int ownerType;
119            public String preferences;
120    }