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.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            @Override
058            public ResourceBlock toEntityModel() {
059                    ResourceBlockImpl resourceBlockImpl = new ResourceBlockImpl();
060    
061                    resourceBlockImpl.setResourceBlockId(resourceBlockId);
062                    resourceBlockImpl.setCompanyId(companyId);
063                    resourceBlockImpl.setGroupId(groupId);
064    
065                    if (name == null) {
066                            resourceBlockImpl.setName(StringPool.BLANK);
067                    }
068                    else {
069                            resourceBlockImpl.setName(name);
070                    }
071    
072                    if (permissionsHash == null) {
073                            resourceBlockImpl.setPermissionsHash(StringPool.BLANK);
074                    }
075                    else {
076                            resourceBlockImpl.setPermissionsHash(permissionsHash);
077                    }
078    
079                    resourceBlockImpl.setReferenceCount(referenceCount);
080    
081                    resourceBlockImpl.resetOriginalValues();
082    
083                    return resourceBlockImpl;
084            }
085    
086            @Override
087            public void readExternal(ObjectInput objectInput) throws IOException {
088                    resourceBlockId = objectInput.readLong();
089                    companyId = objectInput.readLong();
090                    groupId = objectInput.readLong();
091                    name = objectInput.readUTF();
092                    permissionsHash = objectInput.readUTF();
093                    referenceCount = objectInput.readLong();
094            }
095    
096            @Override
097            public void writeExternal(ObjectOutput objectOutput)
098                    throws IOException {
099                    objectOutput.writeLong(resourceBlockId);
100                    objectOutput.writeLong(companyId);
101                    objectOutput.writeLong(groupId);
102    
103                    if (name == null) {
104                            objectOutput.writeUTF(StringPool.BLANK);
105                    }
106                    else {
107                            objectOutput.writeUTF(name);
108                    }
109    
110                    if (permissionsHash == null) {
111                            objectOutput.writeUTF(StringPool.BLANK);
112                    }
113                    else {
114                            objectOutput.writeUTF(permissionsHash);
115                    }
116    
117                    objectOutput.writeLong(referenceCount);
118            }
119    
120            public long resourceBlockId;
121            public long companyId;
122            public long groupId;
123            public String name;
124            public String permissionsHash;
125            public long referenceCount;
126    }