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