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