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.PortalPreferences;
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 PortalPreferences in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see PortalPreferences
032     * @generated
033     */
034    public class PortalPreferencesCacheModel implements CacheModel<PortalPreferences>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(9);
039    
040                    sb.append("{portalPreferencesId=");
041                    sb.append(portalPreferencesId);
042                    sb.append(", ownerId=");
043                    sb.append(ownerId);
044                    sb.append(", ownerType=");
045                    sb.append(ownerType);
046                    sb.append(", preferences=");
047                    sb.append(preferences);
048                    sb.append("}");
049    
050                    return sb.toString();
051            }
052    
053            @Override
054            public PortalPreferences toEntityModel() {
055                    PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
056    
057                    portalPreferencesImpl.setPortalPreferencesId(portalPreferencesId);
058                    portalPreferencesImpl.setOwnerId(ownerId);
059                    portalPreferencesImpl.setOwnerType(ownerType);
060    
061                    if (preferences == null) {
062                            portalPreferencesImpl.setPreferences(StringPool.BLANK);
063                    }
064                    else {
065                            portalPreferencesImpl.setPreferences(preferences);
066                    }
067    
068                    portalPreferencesImpl.resetOriginalValues();
069    
070                    return portalPreferencesImpl;
071            }
072    
073            @Override
074            public void readExternal(ObjectInput objectInput) throws IOException {
075                    portalPreferencesId = objectInput.readLong();
076                    ownerId = objectInput.readLong();
077                    ownerType = objectInput.readInt();
078                    preferences = objectInput.readUTF();
079            }
080    
081            @Override
082            public void writeExternal(ObjectOutput objectOutput)
083                    throws IOException {
084                    objectOutput.writeLong(portalPreferencesId);
085                    objectOutput.writeLong(ownerId);
086                    objectOutput.writeInt(ownerType);
087    
088                    if (preferences == null) {
089                            objectOutput.writeUTF(StringPool.BLANK);
090                    }
091                    else {
092                            objectOutput.writeUTF(preferences);
093                    }
094            }
095    
096            public long portalPreferencesId;
097            public long ownerId;
098            public int ownerType;
099            public String preferences;
100    }