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.ResourcePermission;
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 ResourcePermission in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see ResourcePermission
035     * @generated
036     */
037    @ProviderType
038    public class ResourcePermissionCacheModel implements CacheModel<ResourcePermission>,
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(19);
053    
054                    sb.append("{mvccVersion=");
055                    sb.append(mvccVersion);
056                    sb.append(", resourcePermissionId=");
057                    sb.append(resourcePermissionId);
058                    sb.append(", companyId=");
059                    sb.append(companyId);
060                    sb.append(", name=");
061                    sb.append(name);
062                    sb.append(", scope=");
063                    sb.append(scope);
064                    sb.append(", primKey=");
065                    sb.append(primKey);
066                    sb.append(", roleId=");
067                    sb.append(roleId);
068                    sb.append(", ownerId=");
069                    sb.append(ownerId);
070                    sb.append(", actionIds=");
071                    sb.append(actionIds);
072                    sb.append("}");
073    
074                    return sb.toString();
075            }
076    
077            @Override
078            public ResourcePermission toEntityModel() {
079                    ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
080    
081                    resourcePermissionImpl.setMvccVersion(mvccVersion);
082                    resourcePermissionImpl.setResourcePermissionId(resourcePermissionId);
083                    resourcePermissionImpl.setCompanyId(companyId);
084    
085                    if (name == null) {
086                            resourcePermissionImpl.setName(StringPool.BLANK);
087                    }
088                    else {
089                            resourcePermissionImpl.setName(name);
090                    }
091    
092                    resourcePermissionImpl.setScope(scope);
093    
094                    if (primKey == null) {
095                            resourcePermissionImpl.setPrimKey(StringPool.BLANK);
096                    }
097                    else {
098                            resourcePermissionImpl.setPrimKey(primKey);
099                    }
100    
101                    resourcePermissionImpl.setRoleId(roleId);
102                    resourcePermissionImpl.setOwnerId(ownerId);
103                    resourcePermissionImpl.setActionIds(actionIds);
104    
105                    resourcePermissionImpl.resetOriginalValues();
106    
107                    return resourcePermissionImpl;
108            }
109    
110            @Override
111            public void readExternal(ObjectInput objectInput) throws IOException {
112                    mvccVersion = objectInput.readLong();
113                    resourcePermissionId = objectInput.readLong();
114                    companyId = objectInput.readLong();
115                    name = objectInput.readUTF();
116                    scope = objectInput.readInt();
117                    primKey = objectInput.readUTF();
118                    roleId = objectInput.readLong();
119                    ownerId = objectInput.readLong();
120                    actionIds = objectInput.readLong();
121            }
122    
123            @Override
124            public void writeExternal(ObjectOutput objectOutput)
125                    throws IOException {
126                    objectOutput.writeLong(mvccVersion);
127                    objectOutput.writeLong(resourcePermissionId);
128                    objectOutput.writeLong(companyId);
129    
130                    if (name == null) {
131                            objectOutput.writeUTF(StringPool.BLANK);
132                    }
133                    else {
134                            objectOutput.writeUTF(name);
135                    }
136    
137                    objectOutput.writeInt(scope);
138    
139                    if (primKey == null) {
140                            objectOutput.writeUTF(StringPool.BLANK);
141                    }
142                    else {
143                            objectOutput.writeUTF(primKey);
144                    }
145    
146                    objectOutput.writeLong(roleId);
147                    objectOutput.writeLong(ownerId);
148                    objectOutput.writeLong(actionIds);
149            }
150    
151            public long mvccVersion;
152            public long resourcePermissionId;
153            public long companyId;
154            public String name;
155            public int scope;
156            public String primKey;
157            public long roleId;
158            public long ownerId;
159            public long actionIds;
160    }