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