001
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.ResourceBlock;
024
025 import java.io.Externalizable;
026 import java.io.IOException;
027 import java.io.ObjectInput;
028 import java.io.ObjectOutput;
029
030
037 @ProviderType
038 public class ResourceBlockCacheModel implements CacheModel<ResourceBlock>,
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(15);
053
054 sb.append("{mvccVersion=");
055 sb.append(mvccVersion);
056 sb.append(", resourceBlockId=");
057 sb.append(resourceBlockId);
058 sb.append(", companyId=");
059 sb.append(companyId);
060 sb.append(", groupId=");
061 sb.append(groupId);
062 sb.append(", name=");
063 sb.append(name);
064 sb.append(", permissionsHash=");
065 sb.append(permissionsHash);
066 sb.append(", referenceCount=");
067 sb.append(referenceCount);
068 sb.append("}");
069
070 return sb.toString();
071 }
072
073 @Override
074 public ResourceBlock toEntityModel() {
075 ResourceBlockImpl resourceBlockImpl = new ResourceBlockImpl();
076
077 resourceBlockImpl.setMvccVersion(mvccVersion);
078 resourceBlockImpl.setResourceBlockId(resourceBlockId);
079 resourceBlockImpl.setCompanyId(companyId);
080 resourceBlockImpl.setGroupId(groupId);
081
082 if (name == null) {
083 resourceBlockImpl.setName(StringPool.BLANK);
084 }
085 else {
086 resourceBlockImpl.setName(name);
087 }
088
089 if (permissionsHash == null) {
090 resourceBlockImpl.setPermissionsHash(StringPool.BLANK);
091 }
092 else {
093 resourceBlockImpl.setPermissionsHash(permissionsHash);
094 }
095
096 resourceBlockImpl.setReferenceCount(referenceCount);
097
098 resourceBlockImpl.resetOriginalValues();
099
100 return resourceBlockImpl;
101 }
102
103 @Override
104 public void readExternal(ObjectInput objectInput) throws IOException {
105 mvccVersion = objectInput.readLong();
106 resourceBlockId = objectInput.readLong();
107 companyId = objectInput.readLong();
108 groupId = objectInput.readLong();
109 name = objectInput.readUTF();
110 permissionsHash = objectInput.readUTF();
111 referenceCount = objectInput.readLong();
112 }
113
114 @Override
115 public void writeExternal(ObjectOutput objectOutput)
116 throws IOException {
117 objectOutput.writeLong(mvccVersion);
118 objectOutput.writeLong(resourceBlockId);
119 objectOutput.writeLong(companyId);
120 objectOutput.writeLong(groupId);
121
122 if (name == null) {
123 objectOutput.writeUTF(StringPool.BLANK);
124 }
125 else {
126 objectOutput.writeUTF(name);
127 }
128
129 if (permissionsHash == null) {
130 objectOutput.writeUTF(StringPool.BLANK);
131 }
132 else {
133 objectOutput.writeUTF(permissionsHash);
134 }
135
136 objectOutput.writeLong(referenceCount);
137 }
138
139 public long mvccVersion;
140 public long resourceBlockId;
141 public long companyId;
142 public long groupId;
143 public String name;
144 public String permissionsHash;
145 public long referenceCount;
146 }