001
014
015 package com.liferay.portal.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.model.CacheModel;
020 import com.liferay.portal.kernel.model.MVCCModel;
021 import com.liferay.portal.kernel.model.ResourceAction;
022 import com.liferay.portal.kernel.util.HashUtil;
023 import com.liferay.portal.kernel.util.StringBundler;
024 import com.liferay.portal.kernel.util.StringPool;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031
038 @ProviderType
039 public class ResourceActionCacheModel implements CacheModel<ResourceAction>,
040 Externalizable, MVCCModel {
041 @Override
042 public boolean equals(Object obj) {
043 if (this == obj) {
044 return true;
045 }
046
047 if (!(obj instanceof ResourceActionCacheModel)) {
048 return false;
049 }
050
051 ResourceActionCacheModel resourceActionCacheModel = (ResourceActionCacheModel)obj;
052
053 if ((resourceActionId == resourceActionCacheModel.resourceActionId) &&
054 (mvccVersion == resourceActionCacheModel.mvccVersion)) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 int hashCode = HashUtil.hash(0, resourceActionId);
064
065 return HashUtil.hash(hashCode, mvccVersion);
066 }
067
068 @Override
069 public long getMvccVersion() {
070 return mvccVersion;
071 }
072
073 @Override
074 public void setMvccVersion(long mvccVersion) {
075 this.mvccVersion = mvccVersion;
076 }
077
078 @Override
079 public String toString() {
080 StringBundler sb = new StringBundler(11);
081
082 sb.append("{mvccVersion=");
083 sb.append(mvccVersion);
084 sb.append(", resourceActionId=");
085 sb.append(resourceActionId);
086 sb.append(", name=");
087 sb.append(name);
088 sb.append(", actionId=");
089 sb.append(actionId);
090 sb.append(", bitwiseValue=");
091 sb.append(bitwiseValue);
092 sb.append("}");
093
094 return sb.toString();
095 }
096
097 @Override
098 public ResourceAction toEntityModel() {
099 ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
100
101 resourceActionImpl.setMvccVersion(mvccVersion);
102 resourceActionImpl.setResourceActionId(resourceActionId);
103
104 if (name == null) {
105 resourceActionImpl.setName(StringPool.BLANK);
106 }
107 else {
108 resourceActionImpl.setName(name);
109 }
110
111 if (actionId == null) {
112 resourceActionImpl.setActionId(StringPool.BLANK);
113 }
114 else {
115 resourceActionImpl.setActionId(actionId);
116 }
117
118 resourceActionImpl.setBitwiseValue(bitwiseValue);
119
120 resourceActionImpl.resetOriginalValues();
121
122 return resourceActionImpl;
123 }
124
125 @Override
126 public void readExternal(ObjectInput objectInput) throws IOException {
127 mvccVersion = objectInput.readLong();
128
129 resourceActionId = objectInput.readLong();
130 name = objectInput.readUTF();
131 actionId = objectInput.readUTF();
132
133 bitwiseValue = objectInput.readLong();
134 }
135
136 @Override
137 public void writeExternal(ObjectOutput objectOutput)
138 throws IOException {
139 objectOutput.writeLong(mvccVersion);
140
141 objectOutput.writeLong(resourceActionId);
142
143 if (name == null) {
144 objectOutput.writeUTF(StringPool.BLANK);
145 }
146 else {
147 objectOutput.writeUTF(name);
148 }
149
150 if (actionId == null) {
151 objectOutput.writeUTF(StringPool.BLANK);
152 }
153 else {
154 objectOutput.writeUTF(actionId);
155 }
156
157 objectOutput.writeLong(bitwiseValue);
158 }
159
160 public long mvccVersion;
161 public long resourceActionId;
162 public String name;
163 public String actionId;
164 public long bitwiseValue;
165 }