001// -------------------------------------------------------------------------------- 002// Copyright 2002-2025 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 _stringValue = "{" + 131 "entityId=" + getEntityId() + 132 ", chainInstancePK=" + getChainInstancePK() + 133 ", queuedLetterSequence=" + getQueuedLetterSequence() + 134 ", letterPK=" + getLetterPK() + 135 "}"; 136 } 137 return _stringValue; 138 } 139 140 @Override 141 public boolean equals(Object other) { 142 if(this == other) 143 return true; 144 145 if(!hasIdentity()) 146 return false; 147 148 if(other instanceof QueuedLetterValue that) { 149 if(!that.hasIdentity()) 150 return false; 151 152 Long thisEntityId = getEntityId(); 153 Long thatEntityId = that.getEntityId(); 154 155 boolean objectsEqual = thisEntityId.equals(thatEntityId); 156 if(objectsEqual) 157 objectsEqual = isIdentical(that); 158 159 return objectsEqual; 160 } else { 161 return false; 162 } 163 } 164 165 public boolean isIdentical(Object other) { 166 if(other instanceof QueuedLetterValue that) { 167 boolean objectsEqual = true; 168 169 170 if(objectsEqual) { 171 ChainInstancePK thisChainInstancePK = getChainInstancePK(); 172 ChainInstancePK thatChainInstancePK = that.getChainInstancePK(); 173 174 if(thisChainInstancePK == null) { 175 objectsEqual = objectsEqual && (thatChainInstancePK == null); 176 } else { 177 objectsEqual = objectsEqual && thisChainInstancePK.equals(thatChainInstancePK); 178 } 179 } 180 181 if(objectsEqual) { 182 Integer thisQueuedLetterSequence = getQueuedLetterSequence(); 183 Integer thatQueuedLetterSequence = that.getQueuedLetterSequence(); 184 185 if(thisQueuedLetterSequence == null) { 186 objectsEqual = objectsEqual && (thatQueuedLetterSequence == null); 187 } else { 188 objectsEqual = objectsEqual && thisQueuedLetterSequence.equals(thatQueuedLetterSequence); 189 } 190 } 191 192 if(objectsEqual) { 193 LetterPK thisLetterPK = getLetterPK(); 194 LetterPK thatLetterPK = that.getLetterPK(); 195 196 if(thisLetterPK == null) { 197 objectsEqual = objectsEqual && (thatLetterPK == null); 198 } else { 199 objectsEqual = objectsEqual && thisLetterPK.equals(thatLetterPK); 200 } 201 } 202 203 return objectsEqual; 204 } else { 205 return false; 206 } 207 } 208 209 @Override 210 public boolean hasBeenModified() { 211 return chainInstancePKHasBeenModified || queuedLetterSequenceHasBeenModified || letterPKHasBeenModified; 212 } 213 214 @Override 215 public void clearHasBeenModified() { 216 chainInstancePKHasBeenModified = false; 217 queuedLetterSequenceHasBeenModified = false; 218 letterPKHasBeenModified = false; 219 } 220 221 public ChainInstancePK getChainInstancePK() { 222 return chainInstancePK; 223 } 224 225 public void setChainInstancePK(ChainInstancePK chainInstancePK) 226 throws PersistenceNotNullException { 227 checkForNull(chainInstancePK); 228 229 boolean update = true; 230 231 if(this.chainInstancePK != null) { 232 if(this.chainInstancePK.equals(chainInstancePK)) { 233 update = false; 234 } 235 } else if(chainInstancePK == null) { 236 update = false; 237 } 238 239 if(update) { 240 this.chainInstancePK = chainInstancePK; 241 chainInstancePKHasBeenModified = true; 242 clearHashAndString(); 243 } 244 } 245 246 public boolean getChainInstancePKHasBeenModified() { 247 return chainInstancePKHasBeenModified; 248 } 249 250 public Integer getQueuedLetterSequence() { 251 return queuedLetterSequence; 252 } 253 254 public void setQueuedLetterSequence(Integer queuedLetterSequence) 255 throws PersistenceNotNullException { 256 checkForNull(queuedLetterSequence); 257 258 boolean update = true; 259 260 if(this.queuedLetterSequence != null) { 261 if(this.queuedLetterSequence.equals(queuedLetterSequence)) { 262 update = false; 263 } 264 } else if(queuedLetterSequence == null) { 265 update = false; 266 } 267 268 if(update) { 269 this.queuedLetterSequence = queuedLetterSequence; 270 queuedLetterSequenceHasBeenModified = true; 271 clearHashAndString(); 272 } 273 } 274 275 public boolean getQueuedLetterSequenceHasBeenModified() { 276 return queuedLetterSequenceHasBeenModified; 277 } 278 279 public LetterPK getLetterPK() { 280 return letterPK; 281 } 282 283 public void setLetterPK(LetterPK letterPK) 284 throws PersistenceNotNullException { 285 checkForNull(letterPK); 286 287 boolean update = true; 288 289 if(this.letterPK != null) { 290 if(this.letterPK.equals(letterPK)) { 291 update = false; 292 } 293 } else if(letterPK == null) { 294 update = false; 295 } 296 297 if(update) { 298 this.letterPK = letterPK; 299 letterPKHasBeenModified = true; 300 clearHashAndString(); 301 } 302 } 303 304 public boolean getLetterPKHasBeenModified() { 305 return letterPKHasBeenModified; 306 } 307 308}