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 * EntityBlobAttributeValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.EntityBlobAttributePK; 026 027import com.echothree.model.data.core.server.factory.EntityBlobAttributeFactory; 028 029import com.echothree.model.data.core.common.pk.EntityAttributePK; 030import com.echothree.model.data.core.common.pk.EntityInstancePK; 031import com.echothree.model.data.party.common.pk.LanguagePK; 032import com.echothree.model.data.core.common.pk.MimeTypePK; 033 034import com.echothree.util.common.exception.PersistenceCloneException; 035import com.echothree.util.common.exception.PersistenceNotNullException; 036 037import com.echothree.util.server.persistence.BaseValue; 038 039import java.io.Serializable; 040 041import com.echothree.util.common.persistence.type.ByteArray; 042 043public class EntityBlobAttributeValue 044 extends BaseValue<EntityBlobAttributePK> 045 implements Cloneable, Serializable { 046 047 private EntityAttributePK entityAttributePK; 048 private boolean entityAttributePKHasBeenModified = false; 049 private EntityInstancePK entityInstancePK; 050 private boolean entityInstancePKHasBeenModified = false; 051 private LanguagePK languagePK; 052 private boolean languagePKHasBeenModified = false; 053 private ByteArray blobAttribute; 054 private boolean blobAttributeHasBeenModified = false; 055 private MimeTypePK mimeTypePK; 056 private boolean mimeTypePKHasBeenModified = false; 057 private Long fromTime; 058 private boolean fromTimeHasBeenModified = false; 059 private Long thruTime; 060 private boolean thruTimeHasBeenModified = false; 061 062 private transient Integer _hashCode = null; 063 private transient String _stringValue = null; 064 065 private void constructFields(EntityAttributePK entityAttributePK, EntityInstancePK entityInstancePK, LanguagePK languagePK, ByteArray blobAttribute, MimeTypePK mimeTypePK, Long fromTime, Long thruTime) 066 throws PersistenceNotNullException { 067 checkForNull(entityAttributePK); 068 this.entityAttributePK = entityAttributePK; 069 checkForNull(entityInstancePK); 070 this.entityInstancePK = entityInstancePK; 071 checkForNull(languagePK); 072 this.languagePK = languagePK; 073 checkForNull(blobAttribute); 074 this.blobAttribute = blobAttribute; 075 checkForNull(mimeTypePK); 076 this.mimeTypePK = mimeTypePK; 077 checkForNull(fromTime); 078 this.fromTime = fromTime; 079 checkForNull(thruTime); 080 this.thruTime = thruTime; 081 } 082 083 /** Creates a new instance of EntityBlobAttributeValue */ 084 public EntityBlobAttributeValue(EntityBlobAttributePK entityBlobAttributePK, EntityAttributePK entityAttributePK, EntityInstancePK entityInstancePK, LanguagePK languagePK, ByteArray blobAttribute, MimeTypePK mimeTypePK, Long fromTime, Long thruTime) 085 throws PersistenceNotNullException { 086 super(entityBlobAttributePK); 087 constructFields(entityAttributePK, entityInstancePK, languagePK, blobAttribute, mimeTypePK, fromTime, thruTime); 088 } 089 090 /** Creates a new instance of EntityBlobAttributeValue */ 091 public EntityBlobAttributeValue(EntityAttributePK entityAttributePK, EntityInstancePK entityInstancePK, LanguagePK languagePK, ByteArray blobAttribute, MimeTypePK mimeTypePK, Long fromTime, Long thruTime) 092 throws PersistenceNotNullException { 093 super(); 094 constructFields(entityAttributePK, entityInstancePK, languagePK, blobAttribute, mimeTypePK, fromTime, thruTime); 095 } 096 097 @Override 098 public EntityBlobAttributeFactory getBaseFactoryInstance() { 099 return EntityBlobAttributeFactory.getInstance(); 100 } 101 102 @Override 103 public EntityBlobAttributeValue clone() { 104 Object result; 105 106 try { 107 result = super.clone(); 108 } catch (CloneNotSupportedException cnse) { 109 // This shouldn't happen, fail when it does. 110 throw new PersistenceCloneException(cnse); 111 } 112 113 return (EntityBlobAttributeValue)result; 114 } 115 116 @Override 117 public EntityBlobAttributePK getPrimaryKey() { 118 if(_primaryKey == null) { 119 _primaryKey = new EntityBlobAttributePK(entityId); 120 } 121 122 return _primaryKey; 123 } 124 125 private void clearHashAndString() { 126 _hashCode = null; 127 _stringValue = null; 128 } 129 130 @Override 131 public int hashCode() { 132 if(_hashCode == null) { 133 int hashCode = 17; 134 135 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 136 137 hashCode = 37 * hashCode + ((entityAttributePK != null) ? entityAttributePK.hashCode() : 0); 138 hashCode = 37 * hashCode + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0); 139 hashCode = 37 * hashCode + ((languagePK != null) ? languagePK.hashCode() : 0); 140 hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0); 141 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 142 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 143 144 _hashCode = hashCode; 145 } 146 147 return _hashCode; 148 } 149 150 @Override 151 public String toString() { 152 if(_stringValue == null) { 153 StringBuilder stringValue = new StringBuilder("{"); 154 155 stringValue.append("entityId=").append(getEntityId()); 156 157 stringValue.append(", entityAttributePK=").append(getEntityAttributePK()); 158 stringValue.append(", entityInstancePK=").append(getEntityInstancePK()); 159 stringValue.append(", languagePK=").append(getLanguagePK()); 160 stringValue.append(", mimeTypePK=").append(getMimeTypePK()); 161 stringValue.append(", fromTime=").append(getFromTime()); 162 stringValue.append(", thruTime=").append(getThruTime()); 163 164 stringValue.append('}'); 165 166 _stringValue = stringValue.toString(); 167 } 168 return _stringValue; 169 } 170 171 @Override 172 public boolean equals(Object other) { 173 if(this == other) 174 return true; 175 176 if(!hasIdentity()) 177 return false; 178 179 if(other instanceof EntityBlobAttributeValue) { 180 EntityBlobAttributeValue that = (EntityBlobAttributeValue)other; 181 182 if(!that.hasIdentity()) 183 return false; 184 185 Long thisEntityId = getEntityId(); 186 Long thatEntityId = that.getEntityId(); 187 188 boolean objectsEqual = thisEntityId.equals(thatEntityId); 189 if(objectsEqual) 190 objectsEqual = objectsEqual && isIdentical(that); 191 192 return objectsEqual; 193 } else { 194 return false; 195 } 196 } 197 198 public boolean isIdentical(Object other) { 199 if(other instanceof EntityBlobAttributeValue) { 200 EntityBlobAttributeValue that = (EntityBlobAttributeValue)other; 201 boolean objectsEqual = true; 202 203 204 if(objectsEqual) { 205 EntityAttributePK thisEntityAttributePK = getEntityAttributePK(); 206 EntityAttributePK thatEntityAttributePK = that.getEntityAttributePK(); 207 208 if(thisEntityAttributePK == null) { 209 objectsEqual = objectsEqual && (thatEntityAttributePK == null); 210 } else { 211 objectsEqual = objectsEqual && thisEntityAttributePK.equals(thatEntityAttributePK); 212 } 213 } 214 215 if(objectsEqual) { 216 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 217 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 218 219 if(thisEntityInstancePK == null) { 220 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 221 } else { 222 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 223 } 224 } 225 226 if(objectsEqual) { 227 LanguagePK thisLanguagePK = getLanguagePK(); 228 LanguagePK thatLanguagePK = that.getLanguagePK(); 229 230 if(thisLanguagePK == null) { 231 objectsEqual = objectsEqual && (thatLanguagePK == null); 232 } else { 233 objectsEqual = objectsEqual && thisLanguagePK.equals(thatLanguagePK); 234 } 235 } 236 237 if(objectsEqual) { 238 ByteArray thisBlobAttribute = getBlobAttribute(); 239 ByteArray thatBlobAttribute = that.getBlobAttribute(); 240 241 if(thisBlobAttribute == null) { 242 objectsEqual = objectsEqual && (thatBlobAttribute == null); 243 } else { 244 objectsEqual = objectsEqual && thisBlobAttribute.equals(thatBlobAttribute); 245 } 246 } 247 248 if(objectsEqual) { 249 MimeTypePK thisMimeTypePK = getMimeTypePK(); 250 MimeTypePK thatMimeTypePK = that.getMimeTypePK(); 251 252 if(thisMimeTypePK == null) { 253 objectsEqual = objectsEqual && (thatMimeTypePK == null); 254 } else { 255 objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK); 256 } 257 } 258 259 if(objectsEqual) { 260 Long thisFromTime = getFromTime(); 261 Long thatFromTime = that.getFromTime(); 262 263 if(thisFromTime == null) { 264 objectsEqual = objectsEqual && (thatFromTime == null); 265 } else { 266 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 267 } 268 } 269 270 if(objectsEqual) { 271 Long thisThruTime = getThruTime(); 272 Long thatThruTime = that.getThruTime(); 273 274 if(thisThruTime == null) { 275 objectsEqual = objectsEqual && (thatThruTime == null); 276 } else { 277 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 278 } 279 } 280 281 return objectsEqual; 282 } else { 283 return false; 284 } 285 } 286 287 @Override 288 public boolean hasBeenModified() { 289 return entityAttributePKHasBeenModified || entityInstancePKHasBeenModified || languagePKHasBeenModified || blobAttributeHasBeenModified || mimeTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 290 } 291 292 @Override 293 public void clearHasBeenModified() { 294 entityAttributePKHasBeenModified = false; 295 entityInstancePKHasBeenModified = false; 296 languagePKHasBeenModified = false; 297 blobAttributeHasBeenModified = false; 298 mimeTypePKHasBeenModified = false; 299 fromTimeHasBeenModified = false; 300 thruTimeHasBeenModified = false; 301 } 302 303 public EntityAttributePK getEntityAttributePK() { 304 return entityAttributePK; 305 } 306 307 public void setEntityAttributePK(EntityAttributePK entityAttributePK) 308 throws PersistenceNotNullException { 309 checkForNull(entityAttributePK); 310 311 boolean update = true; 312 313 if(this.entityAttributePK != null) { 314 if(this.entityAttributePK.equals(entityAttributePK)) { 315 update = false; 316 } 317 } else if(entityAttributePK == null) { 318 update = false; 319 } 320 321 if(update) { 322 this.entityAttributePK = entityAttributePK; 323 entityAttributePKHasBeenModified = true; 324 clearHashAndString(); 325 } 326 } 327 328 public boolean getEntityAttributePKHasBeenModified() { 329 return entityAttributePKHasBeenModified; 330 } 331 332 public EntityInstancePK getEntityInstancePK() { 333 return entityInstancePK; 334 } 335 336 public void setEntityInstancePK(EntityInstancePK entityInstancePK) 337 throws PersistenceNotNullException { 338 checkForNull(entityInstancePK); 339 340 boolean update = true; 341 342 if(this.entityInstancePK != null) { 343 if(this.entityInstancePK.equals(entityInstancePK)) { 344 update = false; 345 } 346 } else if(entityInstancePK == null) { 347 update = false; 348 } 349 350 if(update) { 351 this.entityInstancePK = entityInstancePK; 352 entityInstancePKHasBeenModified = true; 353 clearHashAndString(); 354 } 355 } 356 357 public boolean getEntityInstancePKHasBeenModified() { 358 return entityInstancePKHasBeenModified; 359 } 360 361 public LanguagePK getLanguagePK() { 362 return languagePK; 363 } 364 365 public void setLanguagePK(LanguagePK languagePK) 366 throws PersistenceNotNullException { 367 checkForNull(languagePK); 368 369 boolean update = true; 370 371 if(this.languagePK != null) { 372 if(this.languagePK.equals(languagePK)) { 373 update = false; 374 } 375 } else if(languagePK == null) { 376 update = false; 377 } 378 379 if(update) { 380 this.languagePK = languagePK; 381 languagePKHasBeenModified = true; 382 clearHashAndString(); 383 } 384 } 385 386 public boolean getLanguagePKHasBeenModified() { 387 return languagePKHasBeenModified; 388 } 389 390 public ByteArray getBlobAttribute() { 391 return blobAttribute; 392 } 393 394 public void setBlobAttribute(ByteArray blobAttribute) 395 throws PersistenceNotNullException { 396 checkForNull(blobAttribute); 397 398 boolean update = true; 399 400 if(this.blobAttribute != null) { 401 if(this.blobAttribute.equals(blobAttribute)) { 402 update = false; 403 } 404 } else if(blobAttribute == null) { 405 update = false; 406 } 407 408 if(update) { 409 this.blobAttribute = blobAttribute; 410 blobAttributeHasBeenModified = true; 411 clearHashAndString(); 412 } 413 } 414 415 public boolean getBlobAttributeHasBeenModified() { 416 return blobAttributeHasBeenModified; 417 } 418 419 public MimeTypePK getMimeTypePK() { 420 return mimeTypePK; 421 } 422 423 public void setMimeTypePK(MimeTypePK mimeTypePK) 424 throws PersistenceNotNullException { 425 checkForNull(mimeTypePK); 426 427 boolean update = true; 428 429 if(this.mimeTypePK != null) { 430 if(this.mimeTypePK.equals(mimeTypePK)) { 431 update = false; 432 } 433 } else if(mimeTypePK == null) { 434 update = false; 435 } 436 437 if(update) { 438 this.mimeTypePK = mimeTypePK; 439 mimeTypePKHasBeenModified = true; 440 clearHashAndString(); 441 } 442 } 443 444 public boolean getMimeTypePKHasBeenModified() { 445 return mimeTypePKHasBeenModified; 446 } 447 448 public Long getFromTime() { 449 return fromTime; 450 } 451 452 public void setFromTime(Long fromTime) 453 throws PersistenceNotNullException { 454 checkForNull(fromTime); 455 456 boolean update = true; 457 458 if(this.fromTime != null) { 459 if(this.fromTime.equals(fromTime)) { 460 update = false; 461 } 462 } else if(fromTime == null) { 463 update = false; 464 } 465 466 if(update) { 467 this.fromTime = fromTime; 468 fromTimeHasBeenModified = true; 469 clearHashAndString(); 470 } 471 } 472 473 public boolean getFromTimeHasBeenModified() { 474 return fromTimeHasBeenModified; 475 } 476 477 public Long getThruTime() { 478 return thruTime; 479 } 480 481 public void setThruTime(Long thruTime) 482 throws PersistenceNotNullException { 483 checkForNull(thruTime); 484 485 boolean update = true; 486 487 if(this.thruTime != null) { 488 if(this.thruTime.equals(thruTime)) { 489 update = false; 490 } 491 } else if(thruTime == null) { 492 update = false; 493 } 494 495 if(update) { 496 this.thruTime = thruTime; 497 thruTimeHasBeenModified = true; 498 clearHashAndString(); 499 } 500 } 501 502 public boolean getThruTimeHasBeenModified() { 503 return thruTimeHasBeenModified; 504 } 505 506}