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 * InventoryLocationAssignmentStatusValue.java 021 */ 022 023package com.echothree.model.data.inventory.server.value; 024 025import com.echothree.model.data.inventory.common.pk.InventoryLocationAssignmentStatusPK; 026 027import com.echothree.model.data.inventory.server.factory.InventoryLocationAssignmentStatusFactory; 028 029import com.echothree.model.data.inventory.common.pk.InventoryLocationAssignmentPK; 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 038public class InventoryLocationAssignmentStatusValue 039 extends BaseValue<InventoryLocationAssignmentStatusPK> 040 implements Cloneable, Serializable { 041 042 private InventoryLocationAssignmentPK inventoryLocationAssignmentPK; 043 private boolean inventoryLocationAssignmentPKHasBeenModified = false; 044 private Long quantityOnHand; 045 private boolean quantityOnHandHasBeenModified = false; 046 private Long availableToPromise; 047 private boolean availableToPromiseHasBeenModified = false; 048 049 private transient Integer _hashCode = null; 050 private transient String _stringValue = null; 051 052 private void constructFields(InventoryLocationAssignmentPK inventoryLocationAssignmentPK, Long quantityOnHand, Long availableToPromise) 053 throws PersistenceNotNullException { 054 checkForNull(inventoryLocationAssignmentPK); 055 this.inventoryLocationAssignmentPK = inventoryLocationAssignmentPK; 056 checkForNull(quantityOnHand); 057 this.quantityOnHand = quantityOnHand; 058 checkForNull(availableToPromise); 059 this.availableToPromise = availableToPromise; 060 } 061 062 /** Creates a new instance of InventoryLocationAssignmentStatusValue */ 063 public InventoryLocationAssignmentStatusValue(InventoryLocationAssignmentStatusPK inventoryLocationAssignmentStatusPK, InventoryLocationAssignmentPK inventoryLocationAssignmentPK, Long quantityOnHand, Long availableToPromise) 064 throws PersistenceNotNullException { 065 super(inventoryLocationAssignmentStatusPK); 066 constructFields(inventoryLocationAssignmentPK, quantityOnHand, availableToPromise); 067 } 068 069 /** Creates a new instance of InventoryLocationAssignmentStatusValue */ 070 public InventoryLocationAssignmentStatusValue(InventoryLocationAssignmentPK inventoryLocationAssignmentPK, Long quantityOnHand, Long availableToPromise) 071 throws PersistenceNotNullException { 072 super(); 073 constructFields(inventoryLocationAssignmentPK, quantityOnHand, availableToPromise); 074 } 075 076 @Override 077 public InventoryLocationAssignmentStatusFactory getBaseFactoryInstance() { 078 return InventoryLocationAssignmentStatusFactory.getInstance(); 079 } 080 081 @Override 082 public InventoryLocationAssignmentStatusValue clone() { 083 Object result; 084 085 try { 086 result = super.clone(); 087 } catch (CloneNotSupportedException cnse) { 088 // This shouldn't happen, fail when it does. 089 throw new PersistenceCloneException(cnse); 090 } 091 092 return (InventoryLocationAssignmentStatusValue)result; 093 } 094 095 @Override 096 public InventoryLocationAssignmentStatusPK getPrimaryKey() { 097 if(_primaryKey == null) { 098 _primaryKey = new InventoryLocationAssignmentStatusPK(entityId); 099 } 100 101 return _primaryKey; 102 } 103 104 private void clearHashAndString() { 105 _hashCode = null; 106 _stringValue = null; 107 } 108 109 @Override 110 public int hashCode() { 111 if(_hashCode == null) { 112 int hashCode = 17; 113 114 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 115 116 hashCode = 37 * hashCode + ((inventoryLocationAssignmentPK != null) ? inventoryLocationAssignmentPK.hashCode() : 0); 117 hashCode = 37 * hashCode + ((quantityOnHand != null) ? quantityOnHand.hashCode() : 0); 118 hashCode = 37 * hashCode + ((availableToPromise != null) ? availableToPromise.hashCode() : 0); 119 120 _hashCode = hashCode; 121 } 122 123 return _hashCode; 124 } 125 126 @Override 127 public String toString() { 128 if(_stringValue == null) { 129 StringBuilder stringValue = new StringBuilder("{"); 130 131 stringValue.append("entityId=").append(getEntityId()); 132 133 stringValue.append(", inventoryLocationAssignmentPK=").append(getInventoryLocationAssignmentPK()); 134 stringValue.append(", quantityOnHand=").append(getQuantityOnHand()); 135 stringValue.append(", availableToPromise=").append(getAvailableToPromise()); 136 137 stringValue.append('}'); 138 139 _stringValue = stringValue.toString(); 140 } 141 return _stringValue; 142 } 143 144 @Override 145 public boolean equals(Object other) { 146 if(this == other) 147 return true; 148 149 if(!hasIdentity()) 150 return false; 151 152 if(other instanceof InventoryLocationAssignmentStatusValue) { 153 InventoryLocationAssignmentStatusValue that = (InventoryLocationAssignmentStatusValue)other; 154 155 if(!that.hasIdentity()) 156 return false; 157 158 Long thisEntityId = getEntityId(); 159 Long thatEntityId = that.getEntityId(); 160 161 boolean objectsEqual = thisEntityId.equals(thatEntityId); 162 if(objectsEqual) 163 objectsEqual = objectsEqual && isIdentical(that); 164 165 return objectsEqual; 166 } else { 167 return false; 168 } 169 } 170 171 public boolean isIdentical(Object other) { 172 if(other instanceof InventoryLocationAssignmentStatusValue) { 173 InventoryLocationAssignmentStatusValue that = (InventoryLocationAssignmentStatusValue)other; 174 boolean objectsEqual = true; 175 176 177 if(objectsEqual) { 178 InventoryLocationAssignmentPK thisInventoryLocationAssignmentPK = getInventoryLocationAssignmentPK(); 179 InventoryLocationAssignmentPK thatInventoryLocationAssignmentPK = that.getInventoryLocationAssignmentPK(); 180 181 if(thisInventoryLocationAssignmentPK == null) { 182 objectsEqual = objectsEqual && (thatInventoryLocationAssignmentPK == null); 183 } else { 184 objectsEqual = objectsEqual && thisInventoryLocationAssignmentPK.equals(thatInventoryLocationAssignmentPK); 185 } 186 } 187 188 if(objectsEqual) { 189 Long thisQuantityOnHand = getQuantityOnHand(); 190 Long thatQuantityOnHand = that.getQuantityOnHand(); 191 192 if(thisQuantityOnHand == null) { 193 objectsEqual = objectsEqual && (thatQuantityOnHand == null); 194 } else { 195 objectsEqual = objectsEqual && thisQuantityOnHand.equals(thatQuantityOnHand); 196 } 197 } 198 199 if(objectsEqual) { 200 Long thisAvailableToPromise = getAvailableToPromise(); 201 Long thatAvailableToPromise = that.getAvailableToPromise(); 202 203 if(thisAvailableToPromise == null) { 204 objectsEqual = objectsEqual && (thatAvailableToPromise == null); 205 } else { 206 objectsEqual = objectsEqual && thisAvailableToPromise.equals(thatAvailableToPromise); 207 } 208 } 209 210 return objectsEqual; 211 } else { 212 return false; 213 } 214 } 215 216 @Override 217 public boolean hasBeenModified() { 218 return inventoryLocationAssignmentPKHasBeenModified || quantityOnHandHasBeenModified || availableToPromiseHasBeenModified; 219 } 220 221 @Override 222 public void clearHasBeenModified() { 223 inventoryLocationAssignmentPKHasBeenModified = false; 224 quantityOnHandHasBeenModified = false; 225 availableToPromiseHasBeenModified = false; 226 } 227 228 public InventoryLocationAssignmentPK getInventoryLocationAssignmentPK() { 229 return inventoryLocationAssignmentPK; 230 } 231 232 public void setInventoryLocationAssignmentPK(InventoryLocationAssignmentPK inventoryLocationAssignmentPK) 233 throws PersistenceNotNullException { 234 checkForNull(inventoryLocationAssignmentPK); 235 236 boolean update = true; 237 238 if(this.inventoryLocationAssignmentPK != null) { 239 if(this.inventoryLocationAssignmentPK.equals(inventoryLocationAssignmentPK)) { 240 update = false; 241 } 242 } else if(inventoryLocationAssignmentPK == null) { 243 update = false; 244 } 245 246 if(update) { 247 this.inventoryLocationAssignmentPK = inventoryLocationAssignmentPK; 248 inventoryLocationAssignmentPKHasBeenModified = true; 249 clearHashAndString(); 250 } 251 } 252 253 public boolean getInventoryLocationAssignmentPKHasBeenModified() { 254 return inventoryLocationAssignmentPKHasBeenModified; 255 } 256 257 public Long getQuantityOnHand() { 258 return quantityOnHand; 259 } 260 261 public void setQuantityOnHand(Long quantityOnHand) 262 throws PersistenceNotNullException { 263 checkForNull(quantityOnHand); 264 265 boolean update = true; 266 267 if(this.quantityOnHand != null) { 268 if(this.quantityOnHand.equals(quantityOnHand)) { 269 update = false; 270 } 271 } else if(quantityOnHand == null) { 272 update = false; 273 } 274 275 if(update) { 276 this.quantityOnHand = quantityOnHand; 277 quantityOnHandHasBeenModified = true; 278 clearHashAndString(); 279 } 280 } 281 282 public boolean getQuantityOnHandHasBeenModified() { 283 return quantityOnHandHasBeenModified; 284 } 285 286 public Long getAvailableToPromise() { 287 return availableToPromise; 288 } 289 290 public void setAvailableToPromise(Long availableToPromise) 291 throws PersistenceNotNullException { 292 checkForNull(availableToPromise); 293 294 boolean update = true; 295 296 if(this.availableToPromise != null) { 297 if(this.availableToPromise.equals(availableToPromise)) { 298 update = false; 299 } 300 } else if(availableToPromise == null) { 301 update = false; 302 } 303 304 if(update) { 305 this.availableToPromise = availableToPromise; 306 availableToPromiseHasBeenModified = true; 307 clearHashAndString(); 308 } 309 } 310 311 public boolean getAvailableToPromiseHasBeenModified() { 312 return availableToPromiseHasBeenModified; 313 } 314 315}