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