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 * 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            _stringValue = "{" + 
130                    "entityId=" + getEntityId() +
131                    ", inventoryLocationAssignmentPK=" + getInventoryLocationAssignmentPK() +
132                    ", quantityOnHand=" + getQuantityOnHand() +
133                    ", availableToPromise=" + getAvailableToPromise() +
134                    "}";
135        }
136        return _stringValue;
137    }
138    
139    @Override
140    public boolean equals(Object other) {
141        if(this == other)
142            return true;
143        
144        if(!hasIdentity())
145            return false;
146        
147        if(other instanceof  InventoryLocationAssignmentStatusValue that) {
148            if(!that.hasIdentity())
149                return false;
150            
151            Long thisEntityId = getEntityId();
152            Long thatEntityId = that.getEntityId();
153            
154            boolean objectsEqual = thisEntityId.equals(thatEntityId);
155            if(objectsEqual)
156                objectsEqual = isIdentical(that);
157            
158            return objectsEqual;
159        } else {
160            return false;
161        }
162    }
163    
164    public boolean isIdentical(Object other) {
165        if(other instanceof InventoryLocationAssignmentStatusValue that) {
166            boolean objectsEqual = true;
167            
168            
169            if(objectsEqual) {
170                InventoryLocationAssignmentPK thisInventoryLocationAssignmentPK = getInventoryLocationAssignmentPK();
171                InventoryLocationAssignmentPK thatInventoryLocationAssignmentPK = that.getInventoryLocationAssignmentPK();
172                
173                if(thisInventoryLocationAssignmentPK == null) {
174                    objectsEqual = objectsEqual && (thatInventoryLocationAssignmentPK == null);
175                } else {
176                    objectsEqual = objectsEqual && thisInventoryLocationAssignmentPK.equals(thatInventoryLocationAssignmentPK);
177                }
178            }
179            
180            if(objectsEqual) {
181                Long thisQuantityOnHand = getQuantityOnHand();
182                Long thatQuantityOnHand = that.getQuantityOnHand();
183                
184                if(thisQuantityOnHand == null) {
185                    objectsEqual = objectsEqual && (thatQuantityOnHand == null);
186                } else {
187                    objectsEqual = objectsEqual && thisQuantityOnHand.equals(thatQuantityOnHand);
188                }
189            }
190            
191            if(objectsEqual) {
192                Long thisAvailableToPromise = getAvailableToPromise();
193                Long thatAvailableToPromise = that.getAvailableToPromise();
194                
195                if(thisAvailableToPromise == null) {
196                    objectsEqual = objectsEqual && (thatAvailableToPromise == null);
197                } else {
198                    objectsEqual = objectsEqual && thisAvailableToPromise.equals(thatAvailableToPromise);
199                }
200            }
201            
202            return objectsEqual;
203        } else {
204            return false;
205        }
206    }
207    
208    @Override
209    public boolean hasBeenModified() {
210        return inventoryLocationAssignmentPKHasBeenModified || quantityOnHandHasBeenModified || availableToPromiseHasBeenModified;
211    }
212    
213    @Override
214    public void clearHasBeenModified() {
215        inventoryLocationAssignmentPKHasBeenModified = false;
216        quantityOnHandHasBeenModified = false;
217        availableToPromiseHasBeenModified = false;
218    }
219    
220    public InventoryLocationAssignmentPK getInventoryLocationAssignmentPK() {
221        return inventoryLocationAssignmentPK;
222    }
223    
224    public void setInventoryLocationAssignmentPK(InventoryLocationAssignmentPK inventoryLocationAssignmentPK)
225            throws PersistenceNotNullException {
226        checkForNull(inventoryLocationAssignmentPK);
227        
228        boolean update = true;
229        
230        if(this.inventoryLocationAssignmentPK != null) {
231            if(this.inventoryLocationAssignmentPK.equals(inventoryLocationAssignmentPK)) {
232                update = false;
233            }
234        } else if(inventoryLocationAssignmentPK == null) {
235            update = false;
236        }
237        
238        if(update) {
239            this.inventoryLocationAssignmentPK = inventoryLocationAssignmentPK;
240            inventoryLocationAssignmentPKHasBeenModified = true;
241            clearHashAndString();
242        }
243    }
244    
245    public boolean getInventoryLocationAssignmentPKHasBeenModified() {
246        return inventoryLocationAssignmentPKHasBeenModified;
247    }
248    
249    public Long getQuantityOnHand() {
250        return quantityOnHand;
251    }
252    
253    public void setQuantityOnHand(Long quantityOnHand)
254            throws PersistenceNotNullException {
255        checkForNull(quantityOnHand);
256        
257        boolean update = true;
258        
259        if(this.quantityOnHand != null) {
260            if(this.quantityOnHand.equals(quantityOnHand)) {
261                update = false;
262            }
263        } else if(quantityOnHand == null) {
264            update = false;
265        }
266        
267        if(update) {
268            this.quantityOnHand = quantityOnHand;
269            quantityOnHandHasBeenModified = true;
270            clearHashAndString();
271        }
272    }
273    
274    public boolean getQuantityOnHandHasBeenModified() {
275        return quantityOnHandHasBeenModified;
276    }
277    
278    public Long getAvailableToPromise() {
279        return availableToPromise;
280    }
281    
282    public void setAvailableToPromise(Long availableToPromise)
283            throws PersistenceNotNullException {
284        checkForNull(availableToPromise);
285        
286        boolean update = true;
287        
288        if(this.availableToPromise != null) {
289            if(this.availableToPromise.equals(availableToPromise)) {
290                update = false;
291            }
292        } else if(availableToPromise == null) {
293            update = false;
294        }
295        
296        if(update) {
297            this.availableToPromise = availableToPromise;
298            availableToPromiseHasBeenModified = true;
299            clearHashAndString();
300        }
301    }
302    
303    public boolean getAvailableToPromiseHasBeenModified() {
304        return availableToPromiseHasBeenModified;
305    }
306    
307}