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