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