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