001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016// Generated File -- DO NOT EDIT BY HAND 017// -------------------------------------------------------------------------------- 018 019/** 020 * QueuedLetterValue.java 021 */ 022 023package com.echothree.model.data.letter.server.value; 024 025import com.echothree.model.data.letter.common.pk.QueuedLetterPK; 026 027import com.echothree.model.data.letter.server.factory.QueuedLetterFactory; 028 029import com.echothree.model.data.chain.common.pk.ChainInstancePK; 030import com.echothree.model.data.letter.common.pk.LetterPK; 031 032import com.echothree.util.common.exception.PersistenceCloneException; 033import com.echothree.util.common.exception.PersistenceNotNullException; 034 035import com.echothree.util.server.persistence.BaseValue; 036 037import java.io.Serializable; 038 039public class QueuedLetterValue 040 extends BaseValue<QueuedLetterPK> 041 implements Cloneable, Serializable { 042 043 private ChainInstancePK chainInstancePK; 044 private boolean chainInstancePKHasBeenModified = false; 045 private Integer queuedLetterSequence; 046 private boolean queuedLetterSequenceHasBeenModified = false; 047 private LetterPK letterPK; 048 private boolean letterPKHasBeenModified = false; 049 050 private transient Integer _hashCode = null; 051 private transient String _stringValue = null; 052 053 private void constructFields(ChainInstancePK chainInstancePK, Integer queuedLetterSequence, LetterPK letterPK) 054 throws PersistenceNotNullException { 055 checkForNull(chainInstancePK); 056 this.chainInstancePK = chainInstancePK; 057 checkForNull(queuedLetterSequence); 058 this.queuedLetterSequence = queuedLetterSequence; 059 checkForNull(letterPK); 060 this.letterPK = letterPK; 061 } 062 063 /** Creates a new instance of QueuedLetterValue */ 064 public QueuedLetterValue(QueuedLetterPK queuedLetterPK, ChainInstancePK chainInstancePK, Integer queuedLetterSequence, LetterPK letterPK) 065 throws PersistenceNotNullException { 066 super(queuedLetterPK); 067 constructFields(chainInstancePK, queuedLetterSequence, letterPK); 068 } 069 070 /** Creates a new instance of QueuedLetterValue */ 071 public QueuedLetterValue(ChainInstancePK chainInstancePK, Integer queuedLetterSequence, LetterPK letterPK) 072 throws PersistenceNotNullException { 073 super(); 074 constructFields(chainInstancePK, queuedLetterSequence, letterPK); 075 } 076 077 @Override 078 public QueuedLetterFactory getBaseFactoryInstance() { 079 return QueuedLetterFactory.getInstance(); 080 } 081 082 @Override 083 public QueuedLetterValue clone() { 084 Object result; 085 086 try { 087 result = super.clone(); 088 } catch (CloneNotSupportedException cnse) { 089 // This shouldn't happen, fail when it does. 090 throw new PersistenceCloneException(cnse); 091 } 092 093 return (QueuedLetterValue)result; 094 } 095 096 @Override 097 public QueuedLetterPK getPrimaryKey() { 098 if(_primaryKey == null) { 099 _primaryKey = new QueuedLetterPK(entityId); 100 } 101 102 return _primaryKey; 103 } 104 105 private void clearHashAndString() { 106 _hashCode = null; 107 _stringValue = null; 108 } 109 110 @Override 111 public int hashCode() { 112 if(_hashCode == null) { 113 int hashCode = 17; 114 115 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 116 117 hashCode = 37 * hashCode + ((chainInstancePK != null) ? chainInstancePK.hashCode() : 0); 118 hashCode = 37 * hashCode + ((queuedLetterSequence != null) ? queuedLetterSequence.hashCode() : 0); 119 hashCode = 37 * hashCode + ((letterPK != null) ? letterPK.hashCode() : 0); 120 121 _hashCode = hashCode; 122 } 123 124 return _hashCode; 125 } 126 127 @Override 128 public String toString() { 129 if(_stringValue == null) { 130 StringBuilder stringValue = new StringBuilder("{"); 131 132 stringValue.append("entityId=").append(getEntityId()); 133 134 stringValue.append(", chainInstancePK=").append(getChainInstancePK()); 135 stringValue.append(", queuedLetterSequence=").append(getQueuedLetterSequence()); 136 stringValue.append(", letterPK=").append(getLetterPK()); 137 138 stringValue.append('}'); 139 140 _stringValue = stringValue.toString(); 141 } 142 return _stringValue; 143 } 144 145 @Override 146 public boolean equals(Object other) { 147 if(this == other) 148 return true; 149 150 if(!hasIdentity()) 151 return false; 152 153 if(other instanceof QueuedLetterValue) { 154 QueuedLetterValue that = (QueuedLetterValue)other; 155 156 if(!that.hasIdentity()) 157 return false; 158 159 Long thisEntityId = getEntityId(); 160 Long thatEntityId = that.getEntityId(); 161 162 boolean objectsEqual = thisEntityId.equals(thatEntityId); 163 if(objectsEqual) 164 objectsEqual = objectsEqual && isIdentical(that); 165 166 return objectsEqual; 167 } else { 168 return false; 169 } 170 } 171 172 public boolean isIdentical(Object other) { 173 if(other instanceof QueuedLetterValue) { 174 QueuedLetterValue that = (QueuedLetterValue)other; 175 boolean objectsEqual = true; 176 177 178 if(objectsEqual) { 179 ChainInstancePK thisChainInstancePK = getChainInstancePK(); 180 ChainInstancePK thatChainInstancePK = that.getChainInstancePK(); 181 182 if(thisChainInstancePK == null) { 183 objectsEqual = objectsEqual && (thatChainInstancePK == null); 184 } else { 185 objectsEqual = objectsEqual && thisChainInstancePK.equals(thatChainInstancePK); 186 } 187 } 188 189 if(objectsEqual) { 190 Integer thisQueuedLetterSequence = getQueuedLetterSequence(); 191 Integer thatQueuedLetterSequence = that.getQueuedLetterSequence(); 192 193 if(thisQueuedLetterSequence == null) { 194 objectsEqual = objectsEqual && (thatQueuedLetterSequence == null); 195 } else { 196 objectsEqual = objectsEqual && thisQueuedLetterSequence.equals(thatQueuedLetterSequence); 197 } 198 } 199 200 if(objectsEqual) { 201 LetterPK thisLetterPK = getLetterPK(); 202 LetterPK thatLetterPK = that.getLetterPK(); 203 204 if(thisLetterPK == null) { 205 objectsEqual = objectsEqual && (thatLetterPK == null); 206 } else { 207 objectsEqual = objectsEqual && thisLetterPK.equals(thatLetterPK); 208 } 209 } 210 211 return objectsEqual; 212 } else { 213 return false; 214 } 215 } 216 217 @Override 218 public boolean hasBeenModified() { 219 return chainInstancePKHasBeenModified || queuedLetterSequenceHasBeenModified || letterPKHasBeenModified; 220 } 221 222 @Override 223 public void clearHasBeenModified() { 224 chainInstancePKHasBeenModified = false; 225 queuedLetterSequenceHasBeenModified = false; 226 letterPKHasBeenModified = false; 227 } 228 229 public ChainInstancePK getChainInstancePK() { 230 return chainInstancePK; 231 } 232 233 public void setChainInstancePK(ChainInstancePK chainInstancePK) 234 throws PersistenceNotNullException { 235 checkForNull(chainInstancePK); 236 237 boolean update = true; 238 239 if(this.chainInstancePK != null) { 240 if(this.chainInstancePK.equals(chainInstancePK)) { 241 update = false; 242 } 243 } else if(chainInstancePK == null) { 244 update = false; 245 } 246 247 if(update) { 248 this.chainInstancePK = chainInstancePK; 249 chainInstancePKHasBeenModified = true; 250 clearHashAndString(); 251 } 252 } 253 254 public boolean getChainInstancePKHasBeenModified() { 255 return chainInstancePKHasBeenModified; 256 } 257 258 public Integer getQueuedLetterSequence() { 259 return queuedLetterSequence; 260 } 261 262 public void setQueuedLetterSequence(Integer queuedLetterSequence) 263 throws PersistenceNotNullException { 264 checkForNull(queuedLetterSequence); 265 266 boolean update = true; 267 268 if(this.queuedLetterSequence != null) { 269 if(this.queuedLetterSequence.equals(queuedLetterSequence)) { 270 update = false; 271 } 272 } else if(queuedLetterSequence == null) { 273 update = false; 274 } 275 276 if(update) { 277 this.queuedLetterSequence = queuedLetterSequence; 278 queuedLetterSequenceHasBeenModified = true; 279 clearHashAndString(); 280 } 281 } 282 283 public boolean getQueuedLetterSequenceHasBeenModified() { 284 return queuedLetterSequenceHasBeenModified; 285 } 286 287 public LetterPK getLetterPK() { 288 return letterPK; 289 } 290 291 public void setLetterPK(LetterPK letterPK) 292 throws PersistenceNotNullException { 293 checkForNull(letterPK); 294 295 boolean update = true; 296 297 if(this.letterPK != null) { 298 if(this.letterPK.equals(letterPK)) { 299 update = false; 300 } 301 } else if(letterPK == null) { 302 update = false; 303 } 304 305 if(update) { 306 this.letterPK = letterPK; 307 letterPKHasBeenModified = true; 308 clearHashAndString(); 309 } 310 } 311 312 public boolean getLetterPKHasBeenModified() { 313 return letterPKHasBeenModified; 314 } 315 316}