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 * ItemPriceValue.java 021 */ 022 023package com.echothree.model.data.item.server.value; 024 025import com.echothree.model.data.item.common.pk.ItemPricePK; 026 027import com.echothree.model.data.item.server.factory.ItemPriceFactory; 028 029import com.echothree.model.data.item.common.pk.ItemPK; 030import com.echothree.model.data.inventory.common.pk.InventoryConditionPK; 031import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK; 032import com.echothree.model.data.accounting.common.pk.CurrencyPK; 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 javax.annotation.Nonnull; 042import javax.annotation.Nullable; 043 044public class ItemPriceValue 045 extends BaseValue<ItemPricePK> 046 implements Cloneable, Serializable { 047 048 private ItemPK itemPK; 049 private boolean itemPKHasBeenModified = false; 050 private InventoryConditionPK inventoryConditionPK; 051 private boolean inventoryConditionPKHasBeenModified = false; 052 private UnitOfMeasureTypePK unitOfMeasureTypePK; 053 private boolean unitOfMeasureTypePKHasBeenModified = false; 054 private CurrencyPK currencyPK; 055 private boolean currencyPKHasBeenModified = false; 056 private Long fromTime; 057 private boolean fromTimeHasBeenModified = false; 058 private Long thruTime; 059 private boolean thruTimeHasBeenModified = false; 060 061 private transient Integer _hashCode = null; 062 private transient String _stringValue = null; 063 064 private void constructFields(ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime) 065 throws PersistenceNotNullException { 066 checkForNull(itemPK); 067 this.itemPK = itemPK; 068 checkForNull(inventoryConditionPK); 069 this.inventoryConditionPK = inventoryConditionPK; 070 checkForNull(unitOfMeasureTypePK); 071 this.unitOfMeasureTypePK = unitOfMeasureTypePK; 072 checkForNull(currencyPK); 073 this.currencyPK = currencyPK; 074 checkForNull(fromTime); 075 this.fromTime = fromTime; 076 checkForNull(thruTime); 077 this.thruTime = thruTime; 078 } 079 080 /** Creates a new instance of ItemPriceValue */ 081 public ItemPriceValue(ItemPricePK itemPricePK, ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime) 082 throws PersistenceNotNullException { 083 super(itemPricePK); 084 constructFields(itemPK, inventoryConditionPK, unitOfMeasureTypePK, currencyPK, fromTime, thruTime); 085 } 086 087 /** Creates a new instance of ItemPriceValue */ 088 public ItemPriceValue(ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime) 089 throws PersistenceNotNullException { 090 super(); 091 constructFields(itemPK, inventoryConditionPK, unitOfMeasureTypePK, currencyPK, fromTime, thruTime); 092 } 093 094 @Override 095 @Nonnull 096 public ItemPriceFactory getBaseFactoryInstance() { 097 return ItemPriceFactory.getInstance(); 098 } 099 100 @Override 101 @Nonnull 102 public ItemPriceValue clone() { 103 Object result; 104 105 try { 106 result = super.clone(); 107 } catch (CloneNotSupportedException cnse) { 108 // This shouldn't happen, fail when it does. 109 throw new PersistenceCloneException(cnse); 110 } 111 112 return (ItemPriceValue)result; 113 } 114 115 @Override 116 @Nonnull 117 public ItemPricePK getPrimaryKey() { 118 if(_primaryKey == null) { 119 _primaryKey = new ItemPricePK(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 + ((itemPK != null) ? itemPK.hashCode() : 0); 138 hashCode = 37 * hashCode + ((inventoryConditionPK != null) ? inventoryConditionPK.hashCode() : 0); 139 hashCode = 37 * hashCode + ((unitOfMeasureTypePK != null) ? unitOfMeasureTypePK.hashCode() : 0); 140 hashCode = 37 * hashCode + ((currencyPK != null) ? currencyPK.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 @Nonnull 152 public String toString() { 153 if(_stringValue == null) { 154 _stringValue = "{" + 155 "entityId=" + getEntityId() + 156 ", itemPK=" + getItemPK() + 157 ", inventoryConditionPK=" + getInventoryConditionPK() + 158 ", unitOfMeasureTypePK=" + getUnitOfMeasureTypePK() + 159 ", currencyPK=" + getCurrencyPK() + 160 ", fromTime=" + getFromTime() + 161 ", thruTime=" + getThruTime() + 162 "}"; 163 } 164 return _stringValue; 165 } 166 167 @Override 168 public boolean equals(Object other) { 169 if(this == other) 170 return true; 171 172 if(!hasIdentity()) 173 return false; 174 175 if(other instanceof ItemPriceValue that) { 176 if(!that.hasIdentity()) 177 return false; 178 179 Long thisEntityId = getEntityId(); 180 Long thatEntityId = that.getEntityId(); 181 182 boolean objectsEqual = thisEntityId.equals(thatEntityId); 183 if(objectsEqual) 184 objectsEqual = isIdentical(that); 185 186 return objectsEqual; 187 } else { 188 return false; 189 } 190 } 191 192 public boolean isIdentical(Object other) { 193 if(other instanceof ItemPriceValue that) { 194 boolean objectsEqual = true; 195 196 197 if(objectsEqual) { 198 ItemPK thisItemPK = getItemPK(); 199 ItemPK thatItemPK = that.getItemPK(); 200 201 if(thisItemPK == null) { 202 objectsEqual = objectsEqual && (thatItemPK == null); 203 } else { 204 objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK); 205 } 206 } 207 208 if(objectsEqual) { 209 InventoryConditionPK thisInventoryConditionPK = getInventoryConditionPK(); 210 InventoryConditionPK thatInventoryConditionPK = that.getInventoryConditionPK(); 211 212 if(thisInventoryConditionPK == null) { 213 objectsEqual = objectsEqual && (thatInventoryConditionPK == null); 214 } else { 215 objectsEqual = objectsEqual && thisInventoryConditionPK.equals(thatInventoryConditionPK); 216 } 217 } 218 219 if(objectsEqual) { 220 UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK(); 221 UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK(); 222 223 if(thisUnitOfMeasureTypePK == null) { 224 objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null); 225 } else { 226 objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK); 227 } 228 } 229 230 if(objectsEqual) { 231 CurrencyPK thisCurrencyPK = getCurrencyPK(); 232 CurrencyPK thatCurrencyPK = that.getCurrencyPK(); 233 234 if(thisCurrencyPK == null) { 235 objectsEqual = objectsEqual && (thatCurrencyPK == null); 236 } else { 237 objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK); 238 } 239 } 240 241 if(objectsEqual) { 242 Long thisFromTime = getFromTime(); 243 Long thatFromTime = that.getFromTime(); 244 245 if(thisFromTime == null) { 246 objectsEqual = objectsEqual && (thatFromTime == null); 247 } else { 248 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 249 } 250 } 251 252 if(objectsEqual) { 253 Long thisThruTime = getThruTime(); 254 Long thatThruTime = that.getThruTime(); 255 256 if(thisThruTime == null) { 257 objectsEqual = objectsEqual && (thatThruTime == null); 258 } else { 259 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 260 } 261 } 262 263 return objectsEqual; 264 } else { 265 return false; 266 } 267 } 268 269 @Override 270 public boolean hasBeenModified() { 271 return itemPKHasBeenModified || inventoryConditionPKHasBeenModified || unitOfMeasureTypePKHasBeenModified || currencyPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 272 } 273 274 @Override 275 public void clearHasBeenModified() { 276 itemPKHasBeenModified = false; 277 inventoryConditionPKHasBeenModified = false; 278 unitOfMeasureTypePKHasBeenModified = false; 279 currencyPKHasBeenModified = false; 280 fromTimeHasBeenModified = false; 281 thruTimeHasBeenModified = false; 282 } 283 284 @Nonnull 285 public ItemPK getItemPK() { 286 return itemPK; 287 } 288 289 public void setItemPK(@Nonnull ItemPK itemPK) 290 throws PersistenceNotNullException { 291 checkForNull(itemPK); 292 293 boolean update = true; 294 295 if(this.itemPK != null) { 296 if(this.itemPK.equals(itemPK)) { 297 update = false; 298 } 299 } else if(itemPK == null) { 300 update = false; 301 } 302 303 if(update) { 304 this.itemPK = itemPK; 305 itemPKHasBeenModified = true; 306 clearHashAndString(); 307 } 308 } 309 310 public boolean getItemPKHasBeenModified() { 311 return itemPKHasBeenModified; 312 } 313 314 @Nonnull 315 public InventoryConditionPK getInventoryConditionPK() { 316 return inventoryConditionPK; 317 } 318 319 public void setInventoryConditionPK(@Nonnull InventoryConditionPK inventoryConditionPK) 320 throws PersistenceNotNullException { 321 checkForNull(inventoryConditionPK); 322 323 boolean update = true; 324 325 if(this.inventoryConditionPK != null) { 326 if(this.inventoryConditionPK.equals(inventoryConditionPK)) { 327 update = false; 328 } 329 } else if(inventoryConditionPK == null) { 330 update = false; 331 } 332 333 if(update) { 334 this.inventoryConditionPK = inventoryConditionPK; 335 inventoryConditionPKHasBeenModified = true; 336 clearHashAndString(); 337 } 338 } 339 340 public boolean getInventoryConditionPKHasBeenModified() { 341 return inventoryConditionPKHasBeenModified; 342 } 343 344 @Nonnull 345 public UnitOfMeasureTypePK getUnitOfMeasureTypePK() { 346 return unitOfMeasureTypePK; 347 } 348 349 public void setUnitOfMeasureTypePK(@Nonnull UnitOfMeasureTypePK unitOfMeasureTypePK) 350 throws PersistenceNotNullException { 351 checkForNull(unitOfMeasureTypePK); 352 353 boolean update = true; 354 355 if(this.unitOfMeasureTypePK != null) { 356 if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) { 357 update = false; 358 } 359 } else if(unitOfMeasureTypePK == null) { 360 update = false; 361 } 362 363 if(update) { 364 this.unitOfMeasureTypePK = unitOfMeasureTypePK; 365 unitOfMeasureTypePKHasBeenModified = true; 366 clearHashAndString(); 367 } 368 } 369 370 public boolean getUnitOfMeasureTypePKHasBeenModified() { 371 return unitOfMeasureTypePKHasBeenModified; 372 } 373 374 @Nonnull 375 public CurrencyPK getCurrencyPK() { 376 return currencyPK; 377 } 378 379 public void setCurrencyPK(@Nonnull CurrencyPK currencyPK) 380 throws PersistenceNotNullException { 381 checkForNull(currencyPK); 382 383 boolean update = true; 384 385 if(this.currencyPK != null) { 386 if(this.currencyPK.equals(currencyPK)) { 387 update = false; 388 } 389 } else if(currencyPK == null) { 390 update = false; 391 } 392 393 if(update) { 394 this.currencyPK = currencyPK; 395 currencyPKHasBeenModified = true; 396 clearHashAndString(); 397 } 398 } 399 400 public boolean getCurrencyPKHasBeenModified() { 401 return currencyPKHasBeenModified; 402 } 403 404 @Nonnull 405 public Long getFromTime() { 406 return fromTime; 407 } 408 409 public void setFromTime(@Nonnull Long fromTime) 410 throws PersistenceNotNullException { 411 checkForNull(fromTime); 412 413 boolean update = true; 414 415 if(this.fromTime != null) { 416 if(this.fromTime.equals(fromTime)) { 417 update = false; 418 } 419 } else if(fromTime == null) { 420 update = false; 421 } 422 423 if(update) { 424 this.fromTime = fromTime; 425 fromTimeHasBeenModified = true; 426 clearHashAndString(); 427 } 428 } 429 430 public boolean getFromTimeHasBeenModified() { 431 return fromTimeHasBeenModified; 432 } 433 434 @Nonnull 435 public Long getThruTime() { 436 return thruTime; 437 } 438 439 public void setThruTime(@Nonnull Long thruTime) 440 throws PersistenceNotNullException { 441 checkForNull(thruTime); 442 443 boolean update = true; 444 445 if(this.thruTime != null) { 446 if(this.thruTime.equals(thruTime)) { 447 update = false; 448 } 449 } else if(thruTime == null) { 450 update = false; 451 } 452 453 if(update) { 454 this.thruTime = thruTime; 455 thruTimeHasBeenModified = true; 456 clearHashAndString(); 457 } 458 } 459 460 public boolean getThruTimeHasBeenModified() { 461 return thruTimeHasBeenModified; 462 } 463 464}