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 * ItemBlobDescriptionValue.java 021 */ 022 023package com.echothree.model.data.item.server.value; 024 025import com.echothree.model.data.item.common.pk.ItemBlobDescriptionPK; 026 027import com.echothree.model.data.item.server.factory.ItemBlobDescriptionFactory; 028 029import com.echothree.model.data.item.common.pk.ItemDescriptionPK; 030 031import com.echothree.util.common.exception.PersistenceCloneException; 032import com.echothree.util.common.exception.PersistenceNotNullException; 033 034import com.echothree.util.server.persistence.BaseValue; 035 036import java.io.Serializable; 037 038import com.echothree.util.common.persistence.type.ByteArray; 039 040public class ItemBlobDescriptionValue 041 extends BaseValue<ItemBlobDescriptionPK> 042 implements Cloneable, Serializable { 043 044 private ItemDescriptionPK itemDescriptionPK; 045 private boolean itemDescriptionPKHasBeenModified = false; 046 private ByteArray blobDescription; 047 private boolean blobDescriptionHasBeenModified = false; 048 private Long fromTime; 049 private boolean fromTimeHasBeenModified = false; 050 private Long thruTime; 051 private boolean thruTimeHasBeenModified = false; 052 053 private transient Integer _hashCode = null; 054 private transient String _stringValue = null; 055 056 private void constructFields(ItemDescriptionPK itemDescriptionPK, ByteArray blobDescription, Long fromTime, Long thruTime) 057 throws PersistenceNotNullException { 058 checkForNull(itemDescriptionPK); 059 this.itemDescriptionPK = itemDescriptionPK; 060 checkForNull(blobDescription); 061 this.blobDescription = blobDescription; 062 checkForNull(fromTime); 063 this.fromTime = fromTime; 064 checkForNull(thruTime); 065 this.thruTime = thruTime; 066 } 067 068 /** Creates a new instance of ItemBlobDescriptionValue */ 069 public ItemBlobDescriptionValue(ItemBlobDescriptionPK itemBlobDescriptionPK, ItemDescriptionPK itemDescriptionPK, ByteArray blobDescription, Long fromTime, Long thruTime) 070 throws PersistenceNotNullException { 071 super(itemBlobDescriptionPK); 072 constructFields(itemDescriptionPK, blobDescription, fromTime, thruTime); 073 } 074 075 /** Creates a new instance of ItemBlobDescriptionValue */ 076 public ItemBlobDescriptionValue(ItemDescriptionPK itemDescriptionPK, ByteArray blobDescription, Long fromTime, Long thruTime) 077 throws PersistenceNotNullException { 078 super(); 079 constructFields(itemDescriptionPK, blobDescription, fromTime, thruTime); 080 } 081 082 @Override 083 public ItemBlobDescriptionFactory getBaseFactoryInstance() { 084 return ItemBlobDescriptionFactory.getInstance(); 085 } 086 087 @Override 088 public ItemBlobDescriptionValue clone() { 089 Object result; 090 091 try { 092 result = super.clone(); 093 } catch (CloneNotSupportedException cnse) { 094 // This shouldn't happen, fail when it does. 095 throw new PersistenceCloneException(cnse); 096 } 097 098 return (ItemBlobDescriptionValue)result; 099 } 100 101 @Override 102 public ItemBlobDescriptionPK getPrimaryKey() { 103 if(_primaryKey == null) { 104 _primaryKey = new ItemBlobDescriptionPK(entityId); 105 } 106 107 return _primaryKey; 108 } 109 110 private void clearHashAndString() { 111 _hashCode = null; 112 _stringValue = null; 113 } 114 115 @Override 116 public int hashCode() { 117 if(_hashCode == null) { 118 int hashCode = 17; 119 120 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 121 122 hashCode = 37 * hashCode + ((itemDescriptionPK != null) ? itemDescriptionPK.hashCode() : 0); 123 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 124 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 125 126 _hashCode = hashCode; 127 } 128 129 return _hashCode; 130 } 131 132 @Override 133 public String toString() { 134 if(_stringValue == null) { 135 _stringValue = "{" + 136 "entityId=" + getEntityId() + 137 ", itemDescriptionPK=" + getItemDescriptionPK() + 138 ", fromTime=" + getFromTime() + 139 ", thruTime=" + getThruTime() + 140 "}"; 141 } 142 return _stringValue; 143 } 144 145 @Override 146 public boolean equals(Object other) { 147 if(this == other) 148 return true; 149 150 if(!hasIdentity()) 151 return false; 152 153 if(other instanceof ItemBlobDescriptionValue that) { 154 if(!that.hasIdentity()) 155 return false; 156 157 Long thisEntityId = getEntityId(); 158 Long thatEntityId = that.getEntityId(); 159 160 boolean objectsEqual = thisEntityId.equals(thatEntityId); 161 if(objectsEqual) 162 objectsEqual = isIdentical(that); 163 164 return objectsEqual; 165 } else { 166 return false; 167 } 168 } 169 170 public boolean isIdentical(Object other) { 171 if(other instanceof ItemBlobDescriptionValue that) { 172 boolean objectsEqual = true; 173 174 175 if(objectsEqual) { 176 ItemDescriptionPK thisItemDescriptionPK = getItemDescriptionPK(); 177 ItemDescriptionPK thatItemDescriptionPK = that.getItemDescriptionPK(); 178 179 if(thisItemDescriptionPK == null) { 180 objectsEqual = objectsEqual && (thatItemDescriptionPK == null); 181 } else { 182 objectsEqual = objectsEqual && thisItemDescriptionPK.equals(thatItemDescriptionPK); 183 } 184 } 185 186 if(objectsEqual) { 187 ByteArray thisBlobDescription = getBlobDescription(); 188 ByteArray thatBlobDescription = that.getBlobDescription(); 189 190 if(thisBlobDescription == null) { 191 objectsEqual = objectsEqual && (thatBlobDescription == null); 192 } else { 193 objectsEqual = objectsEqual && thisBlobDescription.equals(thatBlobDescription); 194 } 195 } 196 197 if(objectsEqual) { 198 Long thisFromTime = getFromTime(); 199 Long thatFromTime = that.getFromTime(); 200 201 if(thisFromTime == null) { 202 objectsEqual = objectsEqual && (thatFromTime == null); 203 } else { 204 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 205 } 206 } 207 208 if(objectsEqual) { 209 Long thisThruTime = getThruTime(); 210 Long thatThruTime = that.getThruTime(); 211 212 if(thisThruTime == null) { 213 objectsEqual = objectsEqual && (thatThruTime == null); 214 } else { 215 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 216 } 217 } 218 219 return objectsEqual; 220 } else { 221 return false; 222 } 223 } 224 225 @Override 226 public boolean hasBeenModified() { 227 return itemDescriptionPKHasBeenModified || blobDescriptionHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 228 } 229 230 @Override 231 public void clearHasBeenModified() { 232 itemDescriptionPKHasBeenModified = false; 233 blobDescriptionHasBeenModified = false; 234 fromTimeHasBeenModified = false; 235 thruTimeHasBeenModified = false; 236 } 237 238 public ItemDescriptionPK getItemDescriptionPK() { 239 return itemDescriptionPK; 240 } 241 242 public void setItemDescriptionPK(ItemDescriptionPK itemDescriptionPK) 243 throws PersistenceNotNullException { 244 checkForNull(itemDescriptionPK); 245 246 boolean update = true; 247 248 if(this.itemDescriptionPK != null) { 249 if(this.itemDescriptionPK.equals(itemDescriptionPK)) { 250 update = false; 251 } 252 } else if(itemDescriptionPK == null) { 253 update = false; 254 } 255 256 if(update) { 257 this.itemDescriptionPK = itemDescriptionPK; 258 itemDescriptionPKHasBeenModified = true; 259 clearHashAndString(); 260 } 261 } 262 263 public boolean getItemDescriptionPKHasBeenModified() { 264 return itemDescriptionPKHasBeenModified; 265 } 266 267 public ByteArray getBlobDescription() { 268 return blobDescription; 269 } 270 271 public void setBlobDescription(ByteArray blobDescription) 272 throws PersistenceNotNullException { 273 checkForNull(blobDescription); 274 275 boolean update = true; 276 277 if(this.blobDescription != null) { 278 if(this.blobDescription.equals(blobDescription)) { 279 update = false; 280 } 281 } else if(blobDescription == null) { 282 update = false; 283 } 284 285 if(update) { 286 this.blobDescription = blobDescription; 287 blobDescriptionHasBeenModified = true; 288 clearHashAndString(); 289 } 290 } 291 292 public boolean getBlobDescriptionHasBeenModified() { 293 return blobDescriptionHasBeenModified; 294 } 295 296 public Long getFromTime() { 297 return fromTime; 298 } 299 300 public void setFromTime(Long fromTime) 301 throws PersistenceNotNullException { 302 checkForNull(fromTime); 303 304 boolean update = true; 305 306 if(this.fromTime != null) { 307 if(this.fromTime.equals(fromTime)) { 308 update = false; 309 } 310 } else if(fromTime == null) { 311 update = false; 312 } 313 314 if(update) { 315 this.fromTime = fromTime; 316 fromTimeHasBeenModified = true; 317 clearHashAndString(); 318 } 319 } 320 321 public boolean getFromTimeHasBeenModified() { 322 return fromTimeHasBeenModified; 323 } 324 325 public Long getThruTime() { 326 return thruTime; 327 } 328 329 public void setThruTime(Long thruTime) 330 throws PersistenceNotNullException { 331 checkForNull(thruTime); 332 333 boolean update = true; 334 335 if(this.thruTime != null) { 336 if(this.thruTime.equals(thruTime)) { 337 update = false; 338 } 339 } else if(thruTime == null) { 340 update = false; 341 } 342 343 if(update) { 344 this.thruTime = thruTime; 345 thruTimeHasBeenModified = true; 346 clearHashAndString(); 347 } 348 } 349 350 public boolean getThruTimeHasBeenModified() { 351 return thruTimeHasBeenModified; 352 } 353 354}