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.Portlet;
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 Portlet in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see Portlet
032     * @generated
033     */
034    public class PortletCacheModel implements CacheModel<Portlet>, Externalizable {
035            @Override
036            public String toString() {
037                    StringBundler sb = new StringBundler(11);
038    
039                    sb.append("{id=");
040                    sb.append(id);
041                    sb.append(", companyId=");
042                    sb.append(companyId);
043                    sb.append(", portletId=");
044                    sb.append(portletId);
045                    sb.append(", roles=");
046                    sb.append(roles);
047                    sb.append(", active=");
048                    sb.append(active);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            @Override
055            public Portlet toEntityModel() {
056                    PortletImpl portletImpl = new PortletImpl();
057    
058                    portletImpl.setId(id);
059                    portletImpl.setCompanyId(companyId);
060    
061                    if (portletId == null) {
062                            portletImpl.setPortletId(StringPool.BLANK);
063                    }
064                    else {
065                            portletImpl.setPortletId(portletId);
066                    }
067    
068                    if (roles == null) {
069                            portletImpl.setRoles(StringPool.BLANK);
070                    }
071                    else {
072                            portletImpl.setRoles(roles);
073                    }
074    
075                    portletImpl.setActive(active);
076    
077                    portletImpl.resetOriginalValues();
078    
079                    return portletImpl;
080            }
081    
082            @Override
083            public void readExternal(ObjectInput objectInput) throws IOException {
084                    id = objectInput.readLong();
085                    companyId = objectInput.readLong();
086                    portletId = objectInput.readUTF();
087                    roles = objectInput.readUTF();
088                    active = objectInput.readBoolean();
089            }
090    
091            @Override
092            public void writeExternal(ObjectOutput objectOutput)
093                    throws IOException {
094                    objectOutput.writeLong(id);
095                    objectOutput.writeLong(companyId);
096    
097                    if (portletId == null) {
098                            objectOutput.writeUTF(StringPool.BLANK);
099                    }
100                    else {
101                            objectOutput.writeUTF(portletId);
102                    }
103    
104                    if (roles == null) {
105                            objectOutput.writeUTF(StringPool.BLANK);
106                    }
107                    else {
108                            objectOutput.writeUTF(roles);
109                    }
110    
111                    objectOutput.writeBoolean(active);
112            }
113    
114            public long id;
115            public long companyId;
116            public String portletId;
117            public String roles;
118            public boolean active;
119    }