001
014
015 package com.liferay.portal.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023 import com.liferay.portal.model.ClusterGroup;
024 import com.liferay.portal.model.MVCCModel;
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 ClusterGroupCacheModel implements CacheModel<ClusterGroup>,
040 Externalizable, MVCCModel {
041 @Override
042 public boolean equals(Object obj) {
043 if (this == obj) {
044 return true;
045 }
046
047 if (!(obj instanceof ClusterGroupCacheModel)) {
048 return false;
049 }
050
051 ClusterGroupCacheModel clusterGroupCacheModel = (ClusterGroupCacheModel)obj;
052
053 if ((clusterGroupId == clusterGroupCacheModel.clusterGroupId) &&
054 (mvccVersion == clusterGroupCacheModel.mvccVersion)) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 int hashCode = HashUtil.hash(0, clusterGroupId);
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(", clusterGroupId=");
085 sb.append(clusterGroupId);
086 sb.append(", name=");
087 sb.append(name);
088 sb.append(", clusterNodeIds=");
089 sb.append(clusterNodeIds);
090 sb.append(", wholeCluster=");
091 sb.append(wholeCluster);
092 sb.append("}");
093
094 return sb.toString();
095 }
096
097 @Override
098 public ClusterGroup toEntityModel() {
099 ClusterGroupImpl clusterGroupImpl = new ClusterGroupImpl();
100
101 clusterGroupImpl.setMvccVersion(mvccVersion);
102 clusterGroupImpl.setClusterGroupId(clusterGroupId);
103
104 if (name == null) {
105 clusterGroupImpl.setName(StringPool.BLANK);
106 }
107 else {
108 clusterGroupImpl.setName(name);
109 }
110
111 if (clusterNodeIds == null) {
112 clusterGroupImpl.setClusterNodeIds(StringPool.BLANK);
113 }
114 else {
115 clusterGroupImpl.setClusterNodeIds(clusterNodeIds);
116 }
117
118 clusterGroupImpl.setWholeCluster(wholeCluster);
119
120 clusterGroupImpl.resetOriginalValues();
121
122 return clusterGroupImpl;
123 }
124
125 @Override
126 public void readExternal(ObjectInput objectInput) throws IOException {
127 mvccVersion = objectInput.readLong();
128 clusterGroupId = objectInput.readLong();
129 name = objectInput.readUTF();
130 clusterNodeIds = objectInput.readUTF();
131 wholeCluster = objectInput.readBoolean();
132 }
133
134 @Override
135 public void writeExternal(ObjectOutput objectOutput)
136 throws IOException {
137 objectOutput.writeLong(mvccVersion);
138 objectOutput.writeLong(clusterGroupId);
139
140 if (name == null) {
141 objectOutput.writeUTF(StringPool.BLANK);
142 }
143 else {
144 objectOutput.writeUTF(name);
145 }
146
147 if (clusterNodeIds == null) {
148 objectOutput.writeUTF(StringPool.BLANK);
149 }
150 else {
151 objectOutput.writeUTF(clusterNodeIds);
152 }
153
154 objectOutput.writeBoolean(wholeCluster);
155 }
156
157 public long mvccVersion;
158 public long clusterGroupId;
159 public String name;
160 public String clusterNodeIds;
161 public boolean wholeCluster;
162 }