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 * MessageBlobValue.java 021 */ 022 023package com.echothree.model.data.message.server.value; 024 025import com.echothree.model.data.message.common.pk.MessageBlobPK; 026 027import com.echothree.model.data.message.server.factory.MessageBlobFactory; 028 029import com.echothree.model.data.message.common.pk.MessagePK; 030import com.echothree.model.data.party.common.pk.LanguagePK; 031import com.echothree.model.data.core.common.pk.MimeTypePK; 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 com.echothree.util.common.persistence.type.ByteArray; 041 042public class MessageBlobValue 043 extends BaseValue<MessageBlobPK> 044 implements Cloneable, Serializable { 045 046 private MessagePK messagePK; 047 private boolean messagePKHasBeenModified = false; 048 private LanguagePK languagePK; 049 private boolean languagePKHasBeenModified = false; 050 private MimeTypePK mimeTypePK; 051 private boolean mimeTypePKHasBeenModified = false; 052 private ByteArray blob; 053 private boolean blobHasBeenModified = false; 054 private Long fromTime; 055 private boolean fromTimeHasBeenModified = false; 056 private Long thruTime; 057 private boolean thruTimeHasBeenModified = false; 058 059 private transient Integer _hashCode = null; 060 private transient String _stringValue = null; 061 062 private void constructFields(MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime) 063 throws PersistenceNotNullException { 064 checkForNull(messagePK); 065 this.messagePK = messagePK; 066 checkForNull(languagePK); 067 this.languagePK = languagePK; 068 this.mimeTypePK = mimeTypePK; 069 checkForNull(blob); 070 this.blob = blob; 071 checkForNull(fromTime); 072 this.fromTime = fromTime; 073 checkForNull(thruTime); 074 this.thruTime = thruTime; 075 } 076 077 /** Creates a new instance of MessageBlobValue */ 078 public MessageBlobValue(MessageBlobPK messageBlobPK, MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime) 079 throws PersistenceNotNullException { 080 super(messageBlobPK); 081 constructFields(messagePK, languagePK, mimeTypePK, blob, fromTime, thruTime); 082 } 083 084 /** Creates a new instance of MessageBlobValue */ 085 public MessageBlobValue(MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime) 086 throws PersistenceNotNullException { 087 super(); 088 constructFields(messagePK, languagePK, mimeTypePK, blob, fromTime, thruTime); 089 } 090 091 @Override 092 public MessageBlobFactory getBaseFactoryInstance() { 093 return MessageBlobFactory.getInstance(); 094 } 095 096 @Override 097 public MessageBlobValue 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 (MessageBlobValue)result; 108 } 109 110 @Override 111 public MessageBlobPK getPrimaryKey() { 112 if(_primaryKey == null) { 113 _primaryKey = new MessageBlobPK(entityId); 114 } 115 116 return _primaryKey; 117 } 118 119 private void clearHashAndString() { 120 _hashCode = null; 121 _stringValue = null; 122 } 123 124 @Override 125 public int hashCode() { 126 if(_hashCode == null) { 127 int hashCode = 17; 128 129 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 130 131 hashCode = 37 * hashCode + ((messagePK != null) ? messagePK.hashCode() : 0); 132 hashCode = 37 * hashCode + ((languagePK != null) ? languagePK.hashCode() : 0); 133 hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0); 134 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 135 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 136 137 _hashCode = hashCode; 138 } 139 140 return _hashCode; 141 } 142 143 @Override 144 public String toString() { 145 if(_stringValue == null) { 146 _stringValue = "{" + 147 "entityId=" + getEntityId() + 148 ", messagePK=" + getMessagePK() + 149 ", languagePK=" + getLanguagePK() + 150 ", mimeTypePK=" + getMimeTypePK() + 151 ", fromTime=" + getFromTime() + 152 ", thruTime=" + getThruTime() + 153 "}"; 154 } 155 return _stringValue; 156 } 157 158 @Override 159 public boolean equals(Object other) { 160 if(this == other) 161 return true; 162 163 if(!hasIdentity()) 164 return false; 165 166 if(other instanceof MessageBlobValue that) { 167 if(!that.hasIdentity()) 168 return false; 169 170 Long thisEntityId = getEntityId(); 171 Long thatEntityId = that.getEntityId(); 172 173 boolean objectsEqual = thisEntityId.equals(thatEntityId); 174 if(objectsEqual) 175 objectsEqual = isIdentical(that); 176 177 return objectsEqual; 178 } else { 179 return false; 180 } 181 } 182 183 public boolean isIdentical(Object other) { 184 if(other instanceof MessageBlobValue that) { 185 boolean objectsEqual = true; 186 187 188 if(objectsEqual) { 189 MessagePK thisMessagePK = getMessagePK(); 190 MessagePK thatMessagePK = that.getMessagePK(); 191 192 if(thisMessagePK == null) { 193 objectsEqual = objectsEqual && (thatMessagePK == null); 194 } else { 195 objectsEqual = objectsEqual && thisMessagePK.equals(thatMessagePK); 196 } 197 } 198 199 if(objectsEqual) { 200 LanguagePK thisLanguagePK = getLanguagePK(); 201 LanguagePK thatLanguagePK = that.getLanguagePK(); 202 203 if(thisLanguagePK == null) { 204 objectsEqual = objectsEqual && (thatLanguagePK == null); 205 } else { 206 objectsEqual = objectsEqual && thisLanguagePK.equals(thatLanguagePK); 207 } 208 } 209 210 if(objectsEqual) { 211 MimeTypePK thisMimeTypePK = getMimeTypePK(); 212 MimeTypePK thatMimeTypePK = that.getMimeTypePK(); 213 214 if(thisMimeTypePK == null) { 215 objectsEqual = objectsEqual && (thatMimeTypePK == null); 216 } else { 217 objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK); 218 } 219 } 220 221 if(objectsEqual) { 222 ByteArray thisBlob = getBlob(); 223 ByteArray thatBlob = that.getBlob(); 224 225 if(thisBlob == null) { 226 objectsEqual = objectsEqual && (thatBlob == null); 227 } else { 228 objectsEqual = objectsEqual && thisBlob.equals(thatBlob); 229 } 230 } 231 232 if(objectsEqual) { 233 Long thisFromTime = getFromTime(); 234 Long thatFromTime = that.getFromTime(); 235 236 if(thisFromTime == null) { 237 objectsEqual = objectsEqual && (thatFromTime == null); 238 } else { 239 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 240 } 241 } 242 243 if(objectsEqual) { 244 Long thisThruTime = getThruTime(); 245 Long thatThruTime = that.getThruTime(); 246 247 if(thisThruTime == null) { 248 objectsEqual = objectsEqual && (thatThruTime == null); 249 } else { 250 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 251 } 252 } 253 254 return objectsEqual; 255 } else { 256 return false; 257 } 258 } 259 260 @Override 261 public boolean hasBeenModified() { 262 return messagePKHasBeenModified || languagePKHasBeenModified || mimeTypePKHasBeenModified || blobHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 263 } 264 265 @Override 266 public void clearHasBeenModified() { 267 messagePKHasBeenModified = false; 268 languagePKHasBeenModified = false; 269 mimeTypePKHasBeenModified = false; 270 blobHasBeenModified = false; 271 fromTimeHasBeenModified = false; 272 thruTimeHasBeenModified = false; 273 } 274 275 public MessagePK getMessagePK() { 276 return messagePK; 277 } 278 279 public void setMessagePK(MessagePK messagePK) 280 throws PersistenceNotNullException { 281 checkForNull(messagePK); 282 283 boolean update = true; 284 285 if(this.messagePK != null) { 286 if(this.messagePK.equals(messagePK)) { 287 update = false; 288 } 289 } else if(messagePK == null) { 290 update = false; 291 } 292 293 if(update) { 294 this.messagePK = messagePK; 295 messagePKHasBeenModified = true; 296 clearHashAndString(); 297 } 298 } 299 300 public boolean getMessagePKHasBeenModified() { 301 return messagePKHasBeenModified; 302 } 303 304 public LanguagePK getLanguagePK() { 305 return languagePK; 306 } 307 308 public void setLanguagePK(LanguagePK languagePK) 309 throws PersistenceNotNullException { 310 checkForNull(languagePK); 311 312 boolean update = true; 313 314 if(this.languagePK != null) { 315 if(this.languagePK.equals(languagePK)) { 316 update = false; 317 } 318 } else if(languagePK == null) { 319 update = false; 320 } 321 322 if(update) { 323 this.languagePK = languagePK; 324 languagePKHasBeenModified = true; 325 clearHashAndString(); 326 } 327 } 328 329 public boolean getLanguagePKHasBeenModified() { 330 return languagePKHasBeenModified; 331 } 332 333 public MimeTypePK getMimeTypePK() { 334 return mimeTypePK; 335 } 336 337 public void setMimeTypePK(MimeTypePK mimeTypePK) { 338 boolean update = true; 339 340 if(this.mimeTypePK != null) { 341 if(this.mimeTypePK.equals(mimeTypePK)) { 342 update = false; 343 } 344 } else if(mimeTypePK == null) { 345 update = false; 346 } 347 348 if(update) { 349 this.mimeTypePK = mimeTypePK; 350 mimeTypePKHasBeenModified = true; 351 clearHashAndString(); 352 } 353 } 354 355 public boolean getMimeTypePKHasBeenModified() { 356 return mimeTypePKHasBeenModified; 357 } 358 359 public ByteArray getBlob() { 360 return blob; 361 } 362 363 public void setBlob(ByteArray blob) 364 throws PersistenceNotNullException { 365 checkForNull(blob); 366 367 boolean update = true; 368 369 if(this.blob != null) { 370 if(this.blob.equals(blob)) { 371 update = false; 372 } 373 } else if(blob == null) { 374 update = false; 375 } 376 377 if(update) { 378 this.blob = blob; 379 blobHasBeenModified = true; 380 clearHashAndString(); 381 } 382 } 383 384 public boolean getBlobHasBeenModified() { 385 return blobHasBeenModified; 386 } 387 388 public Long getFromTime() { 389 return fromTime; 390 } 391 392 public void setFromTime(Long fromTime) 393 throws PersistenceNotNullException { 394 checkForNull(fromTime); 395 396 boolean update = true; 397 398 if(this.fromTime != null) { 399 if(this.fromTime.equals(fromTime)) { 400 update = false; 401 } 402 } else if(fromTime == null) { 403 update = false; 404 } 405 406 if(update) { 407 this.fromTime = fromTime; 408 fromTimeHasBeenModified = true; 409 clearHashAndString(); 410 } 411 } 412 413 public boolean getFromTimeHasBeenModified() { 414 return fromTimeHasBeenModified; 415 } 416 417 public Long getThruTime() { 418 return thruTime; 419 } 420 421 public void setThruTime(Long thruTime) 422 throws PersistenceNotNullException { 423 checkForNull(thruTime); 424 425 boolean update = true; 426 427 if(this.thruTime != null) { 428 if(this.thruTime.equals(thruTime)) { 429 update = false; 430 } 431 } else if(thruTime == null) { 432 update = false; 433 } 434 435 if(update) { 436 this.thruTime = thruTime; 437 thruTimeHasBeenModified = true; 438 clearHashAndString(); 439 } 440 } 441 442 public boolean getThruTimeHasBeenModified() { 443 return thruTimeHasBeenModified; 444 } 445 446}