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.PortletPreferences;
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 PortletPreferences in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see PortletPreferences
035     * @generated
036     */
037    @ProviderType
038    public class PortletPreferencesCacheModel implements CacheModel<PortletPreferences>,
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(15);
053    
054                    sb.append("{mvccVersion=");
055                    sb.append(mvccVersion);
056                    sb.append(", portletPreferencesId=");
057                    sb.append(portletPreferencesId);
058                    sb.append(", ownerId=");
059                    sb.append(ownerId);
060                    sb.append(", ownerType=");
061                    sb.append(ownerType);
062                    sb.append(", plid=");
063                    sb.append(plid);
064                    sb.append(", portletId=");
065                    sb.append(portletId);
066                    sb.append(", preferences=");
067                    sb.append(preferences);
068                    sb.append("}");
069    
070                    return sb.toString();
071            }
072    
073            @Override
074            public PortletPreferences toEntityModel() {
075                    PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
076    
077                    portletPreferencesImpl.setMvccVersion(mvccVersion);
078                    portletPreferencesImpl.setPortletPreferencesId(portletPreferencesId);
079                    portletPreferencesImpl.setOwnerId(ownerId);
080                    portletPreferencesImpl.setOwnerType(ownerType);
081                    portletPreferencesImpl.setPlid(plid);
082    
083                    if (portletId == null) {
084                            portletPreferencesImpl.setPortletId(StringPool.BLANK);
085                    }
086                    else {
087                            portletPreferencesImpl.setPortletId(portletId);
088                    }
089    
090                    if (preferences == null) {
091                            portletPreferencesImpl.setPreferences(StringPool.BLANK);
092                    }
093                    else {
094                            portletPreferencesImpl.setPreferences(preferences);
095                    }
096    
097                    portletPreferencesImpl.resetOriginalValues();
098    
099                    return portletPreferencesImpl;
100            }
101    
102            @Override
103            public void readExternal(ObjectInput objectInput) throws IOException {
104                    mvccVersion = objectInput.readLong();
105                    portletPreferencesId = objectInput.readLong();
106                    ownerId = objectInput.readLong();
107                    ownerType = objectInput.readInt();
108                    plid = objectInput.readLong();
109                    portletId = objectInput.readUTF();
110                    preferences = objectInput.readUTF();
111            }
112    
113            @Override
114            public void writeExternal(ObjectOutput objectOutput)
115                    throws IOException {
116                    objectOutput.writeLong(mvccVersion);
117                    objectOutput.writeLong(portletPreferencesId);
118                    objectOutput.writeLong(ownerId);
119                    objectOutput.writeInt(ownerType);
120                    objectOutput.writeLong(plid);
121    
122                    if (portletId == null) {
123                            objectOutput.writeUTF(StringPool.BLANK);
124                    }
125                    else {
126                            objectOutput.writeUTF(portletId);
127                    }
128    
129                    if (preferences == null) {
130                            objectOutput.writeUTF(StringPool.BLANK);
131                    }
132                    else {
133                            objectOutput.writeUTF(preferences);
134                    }
135            }
136    
137            public long mvccVersion;
138            public long portletPreferencesId;
139            public long ownerId;
140            public int ownerType;
141            public long plid;
142            public String portletId;
143            public String preferences;
144    }