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 * 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 StringBuilder stringValue = new StringBuilder("{"); 147 148 stringValue.append("entityId=").append(getEntityId()); 149 150 stringValue.append(", messagePK=").append(getMessagePK()); 151 stringValue.append(", languagePK=").append(getLanguagePK()); 152 stringValue.append(", mimeTypePK=").append(getMimeTypePK()); 153 stringValue.append(", fromTime=").append(getFromTime()); 154 stringValue.append(", thruTime=").append(getThruTime()); 155 156 stringValue.append('}'); 157 158 _stringValue = stringValue.toString(); 159 } 160 return _stringValue; 161 } 162 163 @Override 164 public boolean equals(Object other) { 165 if(this == other) 166 return true; 167 168 if(!hasIdentity()) 169 return false; 170 171 if(other instanceof MessageBlobValue) { 172 MessageBlobValue that = (MessageBlobValue)other; 173 174 if(!that.hasIdentity()) 175 return false; 176 177 Long thisEntityId = getEntityId(); 178 Long thatEntityId = that.getEntityId(); 179 180 boolean objectsEqual = thisEntityId.equals(thatEntityId); 181 if(objectsEqual) 182 objectsEqual = objectsEqual && isIdentical(that); 183 184 return objectsEqual; 185 } else { 186 return false; 187 } 188 } 189 190 public boolean isIdentical(Object other) { 191 if(other instanceof MessageBlobValue) { 192 MessageBlobValue that = (MessageBlobValue)other; 193 boolean objectsEqual = true; 194 195 196 if(objectsEqual) { 197 MessagePK thisMessagePK = getMessagePK(); 198 MessagePK thatMessagePK = that.getMessagePK(); 199 200 if(thisMessagePK == null) { 201 objectsEqual = objectsEqual && (thatMessagePK == null); 202 } else { 203 objectsEqual = objectsEqual && thisMessagePK.equals(thatMessagePK); 204 } 205 } 206 207 if(objectsEqual) { 208 LanguagePK thisLanguagePK = getLanguagePK(); 209 LanguagePK thatLanguagePK = that.getLanguagePK(); 210 211 if(thisLanguagePK == null) { 212 objectsEqual = objectsEqual && (thatLanguagePK == null); 213 } else { 214 objectsEqual = objectsEqual && thisLanguagePK.equals(thatLanguagePK); 215 } 216 } 217 218 if(objectsEqual) { 219 MimeTypePK thisMimeTypePK = getMimeTypePK(); 220 MimeTypePK thatMimeTypePK = that.getMimeTypePK(); 221 222 if(thisMimeTypePK == null) { 223 objectsEqual = objectsEqual && (thatMimeTypePK == null); 224 } else { 225 objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK); 226 } 227 } 228 229 if(objectsEqual) { 230 ByteArray thisBlob = getBlob(); 231 ByteArray thatBlob = that.getBlob(); 232 233 if(thisBlob == null) { 234 objectsEqual = objectsEqual && (thatBlob == null); 235 } else { 236 objectsEqual = objectsEqual && thisBlob.equals(thatBlob); 237 } 238 } 239 240 if(objectsEqual) { 241 Long thisFromTime = getFromTime(); 242 Long thatFromTime = that.getFromTime(); 243 244 if(thisFromTime == null) { 245 objectsEqual = objectsEqual && (thatFromTime == null); 246 } else { 247 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 248 } 249 } 250 251 if(objectsEqual) { 252 Long thisThruTime = getThruTime(); 253 Long thatThruTime = that.getThruTime(); 254 255 if(thisThruTime == null) { 256 objectsEqual = objectsEqual && (thatThruTime == null); 257 } else { 258 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 259 } 260 } 261 262 return objectsEqual; 263 } else { 264 return false; 265 } 266 } 267 268 @Override 269 public boolean hasBeenModified() { 270 return messagePKHasBeenModified || languagePKHasBeenModified || mimeTypePKHasBeenModified || blobHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 271 } 272 273 @Override 274 public void clearHasBeenModified() { 275 messagePKHasBeenModified = false; 276 languagePKHasBeenModified = false; 277 mimeTypePKHasBeenModified = false; 278 blobHasBeenModified = false; 279 fromTimeHasBeenModified = false; 280 thruTimeHasBeenModified = false; 281 } 282 283 public MessagePK getMessagePK() { 284 return messagePK; 285 } 286 287 public void setMessagePK(MessagePK messagePK) 288 throws PersistenceNotNullException { 289 checkForNull(messagePK); 290 291 boolean update = true; 292 293 if(this.messagePK != null) { 294 if(this.messagePK.equals(messagePK)) { 295 update = false; 296 } 297 } else if(messagePK == null) { 298 update = false; 299 } 300 301 if(update) { 302 this.messagePK = messagePK; 303 messagePKHasBeenModified = true; 304 clearHashAndString(); 305 } 306 } 307 308 public boolean getMessagePKHasBeenModified() { 309 return messagePKHasBeenModified; 310 } 311 312 public LanguagePK getLanguagePK() { 313 return languagePK; 314 } 315 316 public void setLanguagePK(LanguagePK languagePK) 317 throws PersistenceNotNullException { 318 checkForNull(languagePK); 319 320 boolean update = true; 321 322 if(this.languagePK != null) { 323 if(this.languagePK.equals(languagePK)) { 324 update = false; 325 } 326 } else if(languagePK == null) { 327 update = false; 328 } 329 330 if(update) { 331 this.languagePK = languagePK; 332 languagePKHasBeenModified = true; 333 clearHashAndString(); 334 } 335 } 336 337 public boolean getLanguagePKHasBeenModified() { 338 return languagePKHasBeenModified; 339 } 340 341 public MimeTypePK getMimeTypePK() { 342 return mimeTypePK; 343 } 344 345 public void setMimeTypePK(MimeTypePK mimeTypePK) { 346 boolean update = true; 347 348 if(this.mimeTypePK != null) { 349 if(this.mimeTypePK.equals(mimeTypePK)) { 350 update = false; 351 } 352 } else if(mimeTypePK == null) { 353 update = false; 354 } 355 356 if(update) { 357 this.mimeTypePK = mimeTypePK; 358 mimeTypePKHasBeenModified = true; 359 clearHashAndString(); 360 } 361 } 362 363 public boolean getMimeTypePKHasBeenModified() { 364 return mimeTypePKHasBeenModified; 365 } 366 367 public ByteArray getBlob() { 368 return blob; 369 } 370 371 public void setBlob(ByteArray blob) 372 throws PersistenceNotNullException { 373 checkForNull(blob); 374 375 boolean update = true; 376 377 if(this.blob != null) { 378 if(this.blob.equals(blob)) { 379 update = false; 380 } 381 } else if(blob == null) { 382 update = false; 383 } 384 385 if(update) { 386 this.blob = blob; 387 blobHasBeenModified = true; 388 clearHashAndString(); 389 } 390 } 391 392 public boolean getBlobHasBeenModified() { 393 return blobHasBeenModified; 394 } 395 396 public Long getFromTime() { 397 return fromTime; 398 } 399 400 public void setFromTime(Long fromTime) 401 throws PersistenceNotNullException { 402 checkForNull(fromTime); 403 404 boolean update = true; 405 406 if(this.fromTime != null) { 407 if(this.fromTime.equals(fromTime)) { 408 update = false; 409 } 410 } else if(fromTime == null) { 411 update = false; 412 } 413 414 if(update) { 415 this.fromTime = fromTime; 416 fromTimeHasBeenModified = true; 417 clearHashAndString(); 418 } 419 } 420 421 public boolean getFromTimeHasBeenModified() { 422 return fromTimeHasBeenModified; 423 } 424 425 public Long getThruTime() { 426 return thruTime; 427 } 428 429 public void setThruTime(Long thruTime) 430 throws PersistenceNotNullException { 431 checkForNull(thruTime); 432 433 boolean update = true; 434 435 if(this.thruTime != null) { 436 if(this.thruTime.equals(thruTime)) { 437 update = false; 438 } 439 } else if(thruTime == null) { 440 update = false; 441 } 442 443 if(update) { 444 this.thruTime = thruTime; 445 thruTimeHasBeenModified = true; 446 clearHashAndString(); 447 } 448 } 449 450 public boolean getThruTimeHasBeenModified() { 451 return thruTimeHasBeenModified; 452 } 453 454}