001    /**
002     * Copyright (c) 2000-2012 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.ResourceBlock;
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 ResourceBlock in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see ResourceBlock
032     * @generated
033     */
034    public class ResourceBlockCacheModel implements CacheModel<ResourceBlock>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(13);
039    
040                    sb.append("{resourceBlockId=");
041                    sb.append(resourceBlockId);
042                    sb.append(", companyId=");
043                    sb.append(companyId);
044                    sb.append(", groupId=");
045                    sb.append(groupId);
046                    sb.append(", name=");
047                    sb.append(name);
048                    sb.append(", permissionsHash=");
049                    sb.append(permissionsHash);
050                    sb.append(", referenceCount=");
051                    sb.append(referenceCount);
052                    sb.append("}");
053    
054                    return sb.toString();
055            }
056    
057            public ResourceBlock toEntityModel() {
058                    ResourceBlockImpl resourceBlockImpl = new ResourceBlockImpl();
059    
060                    resourceBlockImpl.setResourceBlockId(resourceBlockId);
061                    resourceBlockImpl.setCompanyId(companyId);
062                    resourceBlockImpl.setGroupId(groupId);
063    
064                    if (name == null) {
065                            resourceBlockImpl.setName(StringPool.BLANK);
066                    }
067                    else {
068                            resourceBlockImpl.setName(name);
069                    }
070    
071                    if (permissionsHash == null) {
072                            resourceBlockImpl.setPermissionsHash(StringPool.BLANK);
073                    }
074                    else {
075                            resourceBlockImpl.setPermissionsHash(permissionsHash);
076                    }
077    
078                    resourceBlockImpl.setReferenceCount(referenceCount);
079    
080                    resourceBlockImpl.resetOriginalValues();
081    
082                    return resourceBlockImpl;
083            }
084    
085            public void readExternal(ObjectInput objectInput) throws IOException {
086                    resourceBlockId = objectInput.readLong();
087                    companyId = objectInput.readLong();
088                    groupId = objectInput.readLong();
089                    name = objectInput.readUTF();
090                    permissionsHash = objectInput.readUTF();
091                    referenceCount = objectInput.readLong();
092            }
093    
094            public void writeExternal(ObjectOutput objectOutput)
095                    throws IOException {
096                    objectOutput.writeLong(resourceBlockId);
097                    objectOutput.writeLong(companyId);
098                    objectOutput.writeLong(groupId);
099    
100                    if (name == null) {
101                            objectOutput.writeUTF(StringPool.BLANK);
102                    }
103                    else {
104                            objectOutput.writeUTF(name);
105                    }
106    
107                    if (permissionsHash == null) {
108                            objectOutput.writeUTF(StringPool.BLANK);
109                    }
110                    else {
111                            objectOutput.writeUTF(permissionsHash);
112                    }
113    
114                    objectOutput.writeLong(referenceCount);
115            }
116    
117            public long resourceBlockId;
118            public long companyId;
119            public long groupId;
120            public String name;
121            public String permissionsHash;
122            public long referenceCount;
123    }