001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 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 * ChainInstanceEntityRoleValue.java 021 */ 022 023package com.echothree.model.data.chain.server.value; 024 025import com.echothree.model.data.chain.common.pk.ChainInstanceEntityRolePK; 026 027import com.echothree.model.data.chain.server.factory.ChainInstanceEntityRoleFactory; 028 029import com.echothree.model.data.chain.common.pk.ChainInstancePK; 030import com.echothree.model.data.chain.common.pk.ChainEntityRoleTypePK; 031import com.echothree.model.data.core.common.pk.EntityInstancePK; 032 033import com.echothree.util.common.exception.PersistenceCloneException; 034import com.echothree.util.common.exception.PersistenceNotNullException; 035 036import com.echothree.util.server.persistence.BaseValue; 037 038import java.io.Serializable; 039 040import javax.annotation.Nonnull; 041import javax.annotation.Nullable; 042 043public class ChainInstanceEntityRoleValue 044 extends BaseValue<ChainInstanceEntityRolePK> 045 implements Cloneable, Serializable { 046 047 private ChainInstancePK chainInstancePK; 048 private boolean chainInstancePKHasBeenModified = false; 049 private ChainEntityRoleTypePK chainEntityRoleTypePK; 050 private boolean chainEntityRoleTypePKHasBeenModified = false; 051 private EntityInstancePK entityInstancePK; 052 private boolean entityInstancePKHasBeenModified = false; 053 private Long fromTime; 054 private boolean fromTimeHasBeenModified = false; 055 private Long thruTime; 056 private boolean thruTimeHasBeenModified = false; 057 058 private transient Integer _hashCode = null; 059 private transient String _stringValue = null; 060 061 private void constructFields(ChainInstancePK chainInstancePK, ChainEntityRoleTypePK chainEntityRoleTypePK, EntityInstancePK entityInstancePK, Long fromTime, Long thruTime) 062 throws PersistenceNotNullException { 063 checkForNull(chainInstancePK); 064 this.chainInstancePK = chainInstancePK; 065 checkForNull(chainEntityRoleTypePK); 066 this.chainEntityRoleTypePK = chainEntityRoleTypePK; 067 checkForNull(entityInstancePK); 068 this.entityInstancePK = entityInstancePK; 069 checkForNull(fromTime); 070 this.fromTime = fromTime; 071 checkForNull(thruTime); 072 this.thruTime = thruTime; 073 } 074 075 /** Creates a new instance of ChainInstanceEntityRoleValue */ 076 public ChainInstanceEntityRoleValue(ChainInstanceEntityRolePK chainInstanceEntityRolePK, ChainInstancePK chainInstancePK, ChainEntityRoleTypePK chainEntityRoleTypePK, EntityInstancePK entityInstancePK, Long fromTime, Long thruTime) 077 throws PersistenceNotNullException { 078 super(chainInstanceEntityRolePK); 079 constructFields(chainInstancePK, chainEntityRoleTypePK, entityInstancePK, fromTime, thruTime); 080 } 081 082 /** Creates a new instance of ChainInstanceEntityRoleValue */ 083 public ChainInstanceEntityRoleValue(ChainInstancePK chainInstancePK, ChainEntityRoleTypePK chainEntityRoleTypePK, EntityInstancePK entityInstancePK, Long fromTime, Long thruTime) 084 throws PersistenceNotNullException { 085 super(); 086 constructFields(chainInstancePK, chainEntityRoleTypePK, entityInstancePK, fromTime, thruTime); 087 } 088 089 @Override 090 @Nonnull 091 public ChainInstanceEntityRoleFactory getBaseFactoryInstance() { 092 return ChainInstanceEntityRoleFactory.getInstance(); 093 } 094 095 @Override 096 @Nonnull 097 public ChainInstanceEntityRoleValue clone() { 098 Object result; 099 100 try { 101 result = super.clone(); 102 } catch (CloneNotSupportedException cnse) { 103 // This shouldn't happen, fail when it does. 104 throw new PersistenceCloneException(cnse); 105 } 106 107 return (ChainInstanceEntityRoleValue)result; 108 } 109 110 @Override 111 @Nonnull 112 public ChainInstanceEntityRolePK getPrimaryKey() { 113 if(_primaryKey == null) { 114 _primaryKey = new ChainInstanceEntityRolePK(entityId); 115 } 116 117 return _primaryKey; 118 } 119 120 private void clearHashAndString() { 121 _hashCode = null; 122 _stringValue = null; 123 } 124 125 @Override 126 public int hashCode() { 127 if(_hashCode == null) { 128 int hashCode = 17; 129 130 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 131 132 hashCode = 37 * hashCode + ((chainInstancePK != null) ? chainInstancePK.hashCode() : 0); 133 hashCode = 37 * hashCode + ((chainEntityRoleTypePK != null) ? chainEntityRoleTypePK.hashCode() : 0); 134 hashCode = 37 * hashCode + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0); 135 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 136 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 137 138 _hashCode = hashCode; 139 } 140 141 return _hashCode; 142 } 143 144 @Override 145 @Nonnull 146 public String toString() { 147 if(_stringValue == null) { 148 _stringValue = "{" + 149 "entityId=" + getEntityId() + 150 ", chainInstancePK=" + getChainInstancePK() + 151 ", chainEntityRoleTypePK=" + getChainEntityRoleTypePK() + 152 ", entityInstancePK=" + getEntityInstancePK() + 153 ", fromTime=" + getFromTime() + 154 ", thruTime=" + getThruTime() + 155 "}"; 156 } 157 return _stringValue; 158 } 159 160 @Override 161 public boolean equals(Object other) { 162 if(this == other) 163 return true; 164 165 if(!hasIdentity()) 166 return false; 167 168 if(other instanceof ChainInstanceEntityRoleValue that) { 169 if(!that.hasIdentity()) 170 return false; 171 172 Long thisEntityId = getEntityId(); 173 Long thatEntityId = that.getEntityId(); 174 175 boolean objectsEqual = thisEntityId.equals(thatEntityId); 176 if(objectsEqual) 177 objectsEqual = isIdentical(that); 178 179 return objectsEqual; 180 } else { 181 return false; 182 } 183 } 184 185 public boolean isIdentical(Object other) { 186 if(other instanceof ChainInstanceEntityRoleValue that) { 187 boolean objectsEqual = true; 188 189 190 if(objectsEqual) { 191 ChainInstancePK thisChainInstancePK = getChainInstancePK(); 192 ChainInstancePK thatChainInstancePK = that.getChainInstancePK(); 193 194 if(thisChainInstancePK == null) { 195 objectsEqual = objectsEqual && (thatChainInstancePK == null); 196 } else { 197 objectsEqual = objectsEqual && thisChainInstancePK.equals(thatChainInstancePK); 198 } 199 } 200 201 if(objectsEqual) { 202 ChainEntityRoleTypePK thisChainEntityRoleTypePK = getChainEntityRoleTypePK(); 203 ChainEntityRoleTypePK thatChainEntityRoleTypePK = that.getChainEntityRoleTypePK(); 204 205 if(thisChainEntityRoleTypePK == null) { 206 objectsEqual = objectsEqual && (thatChainEntityRoleTypePK == null); 207 } else { 208 objectsEqual = objectsEqual && thisChainEntityRoleTypePK.equals(thatChainEntityRoleTypePK); 209 } 210 } 211 212 if(objectsEqual) { 213 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 214 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 215 216 if(thisEntityInstancePK == null) { 217 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 218 } else { 219 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 220 } 221 } 222 223 if(objectsEqual) { 224 Long thisFromTime = getFromTime(); 225 Long thatFromTime = that.getFromTime(); 226 227 if(thisFromTime == null) { 228 objectsEqual = objectsEqual && (thatFromTime == null); 229 } else { 230 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 231 } 232 } 233 234 if(objectsEqual) { 235 Long thisThruTime = getThruTime(); 236 Long thatThruTime = that.getThruTime(); 237 238 if(thisThruTime == null) { 239 objectsEqual = objectsEqual && (thatThruTime == null); 240 } else { 241 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 242 } 243 } 244 245 return objectsEqual; 246 } else { 247 return false; 248 } 249 } 250 251 @Override 252 public boolean hasBeenModified() { 253 return chainInstancePKHasBeenModified || chainEntityRoleTypePKHasBeenModified || entityInstancePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 254 } 255 256 @Override 257 public void clearHasBeenModified() { 258 chainInstancePKHasBeenModified = false; 259 chainEntityRoleTypePKHasBeenModified = false; 260 entityInstancePKHasBeenModified = false; 261 fromTimeHasBeenModified = false; 262 thruTimeHasBeenModified = false; 263 } 264 265 @Nonnull 266 public ChainInstancePK getChainInstancePK() { 267 return chainInstancePK; 268 } 269 270 public void setChainInstancePK(@Nonnull ChainInstancePK chainInstancePK) 271 throws PersistenceNotNullException { 272 checkForNull(chainInstancePK); 273 274 boolean update = true; 275 276 if(this.chainInstancePK != null) { 277 if(this.chainInstancePK.equals(chainInstancePK)) { 278 update = false; 279 } 280 } else if(chainInstancePK == null) { 281 update = false; 282 } 283 284 if(update) { 285 this.chainInstancePK = chainInstancePK; 286 chainInstancePKHasBeenModified = true; 287 clearHashAndString(); 288 } 289 } 290 291 public boolean getChainInstancePKHasBeenModified() { 292 return chainInstancePKHasBeenModified; 293 } 294 295 @Nonnull 296 public ChainEntityRoleTypePK getChainEntityRoleTypePK() { 297 return chainEntityRoleTypePK; 298 } 299 300 public void setChainEntityRoleTypePK(@Nonnull ChainEntityRoleTypePK chainEntityRoleTypePK) 301 throws PersistenceNotNullException { 302 checkForNull(chainEntityRoleTypePK); 303 304 boolean update = true; 305 306 if(this.chainEntityRoleTypePK != null) { 307 if(this.chainEntityRoleTypePK.equals(chainEntityRoleTypePK)) { 308 update = false; 309 } 310 } else if(chainEntityRoleTypePK == null) { 311 update = false; 312 } 313 314 if(update) { 315 this.chainEntityRoleTypePK = chainEntityRoleTypePK; 316 chainEntityRoleTypePKHasBeenModified = true; 317 clearHashAndString(); 318 } 319 } 320 321 public boolean getChainEntityRoleTypePKHasBeenModified() { 322 return chainEntityRoleTypePKHasBeenModified; 323 } 324 325 @Nonnull 326 public EntityInstancePK getEntityInstancePK() { 327 return entityInstancePK; 328 } 329 330 public void setEntityInstancePK(@Nonnull EntityInstancePK entityInstancePK) 331 throws PersistenceNotNullException { 332 checkForNull(entityInstancePK); 333 334 boolean update = true; 335 336 if(this.entityInstancePK != null) { 337 if(this.entityInstancePK.equals(entityInstancePK)) { 338 update = false; 339 } 340 } else if(entityInstancePK == null) { 341 update = false; 342 } 343 344 if(update) { 345 this.entityInstancePK = entityInstancePK; 346 entityInstancePKHasBeenModified = true; 347 clearHashAndString(); 348 } 349 } 350 351 public boolean getEntityInstancePKHasBeenModified() { 352 return entityInstancePKHasBeenModified; 353 } 354 355 @Nonnull 356 public Long getFromTime() { 357 return fromTime; 358 } 359 360 public void setFromTime(@Nonnull Long fromTime) 361 throws PersistenceNotNullException { 362 checkForNull(fromTime); 363 364 boolean update = true; 365 366 if(this.fromTime != null) { 367 if(this.fromTime.equals(fromTime)) { 368 update = false; 369 } 370 } else if(fromTime == null) { 371 update = false; 372 } 373 374 if(update) { 375 this.fromTime = fromTime; 376 fromTimeHasBeenModified = true; 377 clearHashAndString(); 378 } 379 } 380 381 public boolean getFromTimeHasBeenModified() { 382 return fromTimeHasBeenModified; 383 } 384 385 @Nonnull 386 public Long getThruTime() { 387 return thruTime; 388 } 389 390 public void setThruTime(@Nonnull Long thruTime) 391 throws PersistenceNotNullException { 392 checkForNull(thruTime); 393 394 boolean update = true; 395 396 if(this.thruTime != null) { 397 if(this.thruTime.equals(thruTime)) { 398 update = false; 399 } 400 } else if(thruTime == null) { 401 update = false; 402 } 403 404 if(update) { 405 this.thruTime = thruTime; 406 thruTimeHasBeenModified = true; 407 clearHashAndString(); 408 } 409 } 410 411 public boolean getThruTimeHasBeenModified() { 412 return thruTimeHasBeenModified; 413 } 414 415}