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.ClusterGroup;
021 import com.liferay.portal.kernel.model.MVCCModel;
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 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
129 clusterGroupId = objectInput.readLong();
130 name = objectInput.readUTF();
131 clusterNodeIds = objectInput.readUTF();
132
133 wholeCluster = objectInput.readBoolean();
134 }
135
136 @Override
137 public void writeExternal(ObjectOutput objectOutput)
138 throws IOException {
139 objectOutput.writeLong(mvccVersion);
140
141 objectOutput.writeLong(clusterGroupId);
142
143 if (name == null) {
144 objectOutput.writeUTF(StringPool.BLANK);
145 }
146 else {
147 objectOutput.writeUTF(name);
148 }
149
150 if (clusterNodeIds == null) {
151 objectOutput.writeUTF(StringPool.BLANK);
152 }
153 else {
154 objectOutput.writeUTF(clusterNodeIds);
155 }
156
157 objectOutput.writeBoolean(wholeCluster);
158 }
159
160 public long mvccVersion;
161 public long clusterGroupId;
162 public String name;
163 public String clusterNodeIds;
164 public boolean wholeCluster;
165 }