001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 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            StringBuilder stringValue = new StringBuilder("{");
143            
144            stringValue.append("entityId=").append(getEntityId());
145            
146            stringValue.append(", itemPK=").append(getItemPK());
147            stringValue.append(", unitOfMeasureTypePK=").append(getUnitOfMeasureTypePK());
148            stringValue.append(", minimumQuantity=").append(getMinimumQuantity());
149            stringValue.append(", maximumQuantity=").append(getMaximumQuantity());
150            stringValue.append(", fromTime=").append(getFromTime());
151            stringValue.append(", thruTime=").append(getThruTime());
152            
153            stringValue.append('}');
154            
155            _stringValue = stringValue.toString();
156        }
157        return _stringValue;
158    }
159    
160    @Override
161    public boolean equals(Object other) {
162        if(this == other)
163            return true;
164        
165        if(!hasIdentity())
166            return false;
167        
168        if(other instanceof  ItemPackCheckRequirementValue) {
169            ItemPackCheckRequirementValue that = (ItemPackCheckRequirementValue)other;
170            
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 = 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) {
189            ItemPackCheckRequirementValue that = (ItemPackCheckRequirementValue)other;
190            boolean objectsEqual = true;
191            
192            
193            if(objectsEqual) {
194                ItemPK thisItemPK = getItemPK();
195                ItemPK thatItemPK = that.getItemPK();
196                
197                if(thisItemPK == null) {
198                    objectsEqual = objectsEqual && (thatItemPK == null);
199                } else {
200                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
201                }
202            }
203            
204            if(objectsEqual) {
205                UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK();
206                UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK();
207                
208                if(thisUnitOfMeasureTypePK == null) {
209                    objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null);
210                } else {
211                    objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK);
212                }
213            }
214            
215            if(objectsEqual) {
216                Long thisMinimumQuantity = getMinimumQuantity();
217                Long thatMinimumQuantity = that.getMinimumQuantity();
218                
219                if(thisMinimumQuantity == null) {
220                    objectsEqual = objectsEqual && (thatMinimumQuantity == null);
221                } else {
222                    objectsEqual = objectsEqual && thisMinimumQuantity.equals(thatMinimumQuantity);
223                }
224            }
225            
226            if(objectsEqual) {
227                Long thisMaximumQuantity = getMaximumQuantity();
228                Long thatMaximumQuantity = that.getMaximumQuantity();
229                
230                if(thisMaximumQuantity == null) {
231                    objectsEqual = objectsEqual && (thatMaximumQuantity == null);
232                } else {
233                    objectsEqual = objectsEqual && thisMaximumQuantity.equals(thatMaximumQuantity);
234                }
235            }
236            
237            if(objectsEqual) {
238                Long thisFromTime = getFromTime();
239                Long thatFromTime = that.getFromTime();
240                
241                if(thisFromTime == null) {
242                    objectsEqual = objectsEqual && (thatFromTime == null);
243                } else {
244                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
245                }
246            }
247            
248            if(objectsEqual) {
249                Long thisThruTime = getThruTime();
250                Long thatThruTime = that.getThruTime();
251                
252                if(thisThruTime == null) {
253                    objectsEqual = objectsEqual && (thatThruTime == null);
254                } else {
255                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
256                }
257            }
258            
259            return objectsEqual;
260        } else {
261            return false;
262        }
263    }
264    
265    @Override
266    public boolean hasBeenModified() {
267        return itemPKHasBeenModified || unitOfMeasureTypePKHasBeenModified || minimumQuantityHasBeenModified || maximumQuantityHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
268    }
269    
270    @Override
271    public void clearHasBeenModified() {
272        itemPKHasBeenModified = false;
273        unitOfMeasureTypePKHasBeenModified = false;
274        minimumQuantityHasBeenModified = false;
275        maximumQuantityHasBeenModified = false;
276        fromTimeHasBeenModified = false;
277        thruTimeHasBeenModified = false;
278    }
279    
280    public ItemPK getItemPK() {
281        return itemPK;
282    }
283    
284    public void setItemPK(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    public UnitOfMeasureTypePK getUnitOfMeasureTypePK() {
310        return unitOfMeasureTypePK;
311    }
312    
313    public void setUnitOfMeasureTypePK(UnitOfMeasureTypePK unitOfMeasureTypePK) {
314        boolean update = true;
315        
316        if(this.unitOfMeasureTypePK != null) {
317            if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) {
318                update = false;
319            }
320        } else if(unitOfMeasureTypePK == null) {
321            update = false;
322        }
323        
324        if(update) {
325            this.unitOfMeasureTypePK = unitOfMeasureTypePK;
326            unitOfMeasureTypePKHasBeenModified = true;
327            clearHashAndString();
328        }
329    }
330    
331    public boolean getUnitOfMeasureTypePKHasBeenModified() {
332        return unitOfMeasureTypePKHasBeenModified;
333    }
334    
335    public Long getMinimumQuantity() {
336        return minimumQuantity;
337    }
338    
339    public void setMinimumQuantity(Long minimumQuantity) {
340        boolean update = true;
341        
342        if(this.minimumQuantity != null) {
343            if(this.minimumQuantity.equals(minimumQuantity)) {
344                update = false;
345            }
346        } else if(minimumQuantity == null) {
347            update = false;
348        }
349        
350        if(update) {
351            this.minimumQuantity = minimumQuantity;
352            minimumQuantityHasBeenModified = true;
353            clearHashAndString();
354        }
355    }
356    
357    public boolean getMinimumQuantityHasBeenModified() {
358        return minimumQuantityHasBeenModified;
359    }
360    
361    public Long getMaximumQuantity() {
362        return maximumQuantity;
363    }
364    
365    public void setMaximumQuantity(Long maximumQuantity) {
366        boolean update = true;
367        
368        if(this.maximumQuantity != null) {
369            if(this.maximumQuantity.equals(maximumQuantity)) {
370                update = false;
371            }
372        } else if(maximumQuantity == null) {
373            update = false;
374        }
375        
376        if(update) {
377            this.maximumQuantity = maximumQuantity;
378            maximumQuantityHasBeenModified = true;
379            clearHashAndString();
380        }
381    }
382    
383    public boolean getMaximumQuantityHasBeenModified() {
384        return maximumQuantityHasBeenModified;
385    }
386    
387    public Long getFromTime() {
388        return fromTime;
389    }
390    
391    public void setFromTime(Long fromTime)
392            throws PersistenceNotNullException {
393        checkForNull(fromTime);
394        
395        boolean update = true;
396        
397        if(this.fromTime != null) {
398            if(this.fromTime.equals(fromTime)) {
399                update = false;
400            }
401        } else if(fromTime == null) {
402            update = false;
403        }
404        
405        if(update) {
406            this.fromTime = fromTime;
407            fromTimeHasBeenModified = true;
408            clearHashAndString();
409        }
410    }
411    
412    public boolean getFromTimeHasBeenModified() {
413        return fromTimeHasBeenModified;
414    }
415    
416    public Long getThruTime() {
417        return thruTime;
418    }
419    
420    public void setThruTime(Long thruTime)
421            throws PersistenceNotNullException {
422        checkForNull(thruTime);
423        
424        boolean update = true;
425        
426        if(this.thruTime != null) {
427            if(this.thruTime.equals(thruTime)) {
428                update = false;
429            }
430        } else if(thruTime == null) {
431            update = false;
432        }
433        
434        if(update) {
435            this.thruTime = thruTime;
436            thruTimeHasBeenModified = true;
437            clearHashAndString();
438        }
439    }
440    
441    public boolean getThruTimeHasBeenModified() {
442        return thruTimeHasBeenModified;
443    }
444    
445}