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