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