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 * ItemAdditionalChargeValue.java
021 */
022
023package com.echothree.model.data.item.server.value;
024
025import com.echothree.model.data.item.common.pk.ItemAdditionalChargePK;
026
027import com.echothree.model.data.item.server.factory.ItemAdditionalChargeFactory;
028
029import com.echothree.model.data.item.common.pk.ItemPK;
030import com.echothree.model.data.item.common.pk.ItemAdditionalChargeTypePK;
031import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK;
032import com.echothree.model.data.accounting.common.pk.CurrencyPK;
033
034import com.echothree.util.common.exception.PersistenceCloneException;
035import com.echothree.util.common.exception.PersistenceNotNullException;
036
037import com.echothree.util.server.persistence.BaseValue;
038
039import java.io.Serializable;
040
041import javax.annotation.Nonnull;
042import javax.annotation.Nullable;
043
044public class ItemAdditionalChargeValue
045        extends BaseValue<ItemAdditionalChargePK>
046        implements Cloneable, Serializable {
047    
048    private ItemPK itemPK;
049    private boolean itemPKHasBeenModified = false;
050    private ItemAdditionalChargeTypePK itemAdditionalChargeTypePK;
051    private boolean itemAdditionalChargeTypePKHasBeenModified = false;
052    private UnitOfMeasureTypePK unitOfMeasureTypePK;
053    private boolean unitOfMeasureTypePKHasBeenModified = false;
054    private Long minimumQuantity;
055    private boolean minimumQuantityHasBeenModified = false;
056    private Long maximumQuantity;
057    private boolean maximumQuantityHasBeenModified = false;
058    private CurrencyPK currencyPK;
059    private boolean currencyPKHasBeenModified = false;
060    private Long unitPrice;
061    private boolean unitPriceHasBeenModified = false;
062    private Long fromTime;
063    private boolean fromTimeHasBeenModified = false;
064    private Long thruTime;
065    private boolean thruTimeHasBeenModified = false;
066    
067    private transient Integer _hashCode = null;
068    private transient String _stringValue = null;
069    
070    private void constructFields(ItemPK itemPK, ItemAdditionalChargeTypePK itemAdditionalChargeTypePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long minimumQuantity, Long maximumQuantity, CurrencyPK currencyPK, Long unitPrice, Long fromTime, Long thruTime)
071            throws PersistenceNotNullException {
072        checkForNull(itemPK);
073        this.itemPK = itemPK;
074        checkForNull(itemAdditionalChargeTypePK);
075        this.itemAdditionalChargeTypePK = itemAdditionalChargeTypePK;
076        this.unitOfMeasureTypePK = unitOfMeasureTypePK;
077        this.minimumQuantity = minimumQuantity;
078        this.maximumQuantity = maximumQuantity;
079        checkForNull(currencyPK);
080        this.currencyPK = currencyPK;
081        checkForNull(unitPrice);
082        this.unitPrice = unitPrice;
083        checkForNull(fromTime);
084        this.fromTime = fromTime;
085        checkForNull(thruTime);
086        this.thruTime = thruTime;
087    }
088    
089    /** Creates a new instance of ItemAdditionalChargeValue */
090    public ItemAdditionalChargeValue(ItemAdditionalChargePK itemAdditionalChargePK, ItemPK itemPK, ItemAdditionalChargeTypePK itemAdditionalChargeTypePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long minimumQuantity, Long maximumQuantity, CurrencyPK currencyPK, Long unitPrice, Long fromTime, Long thruTime)
091            throws PersistenceNotNullException {
092        super(itemAdditionalChargePK);
093        constructFields(itemPK, itemAdditionalChargeTypePK, unitOfMeasureTypePK, minimumQuantity, maximumQuantity, currencyPK, unitPrice, fromTime, thruTime);
094    }
095    
096    /** Creates a new instance of ItemAdditionalChargeValue */
097    public ItemAdditionalChargeValue(ItemPK itemPK, ItemAdditionalChargeTypePK itemAdditionalChargeTypePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long minimumQuantity, Long maximumQuantity, CurrencyPK currencyPK, Long unitPrice, Long fromTime, Long thruTime)
098            throws PersistenceNotNullException {
099        super();
100        constructFields(itemPK, itemAdditionalChargeTypePK, unitOfMeasureTypePK, minimumQuantity, maximumQuantity, currencyPK, unitPrice, fromTime, thruTime);
101    }
102    
103    @Override
104    @Nonnull
105    public ItemAdditionalChargeFactory getBaseFactoryInstance() {
106        return ItemAdditionalChargeFactory.getInstance();
107    }
108    
109    @Override
110    @Nonnull
111    public ItemAdditionalChargeValue clone() {
112        Object result;
113        
114        try {
115            result = super.clone();
116        } catch (CloneNotSupportedException cnse) {
117            // This shouldn't happen, fail when it does.
118            throw new PersistenceCloneException(cnse);
119        }
120        
121        return (ItemAdditionalChargeValue)result;
122    }
123    
124    @Override
125    @Nonnull
126    public ItemAdditionalChargePK getPrimaryKey() {
127        if(_primaryKey == null) {
128            _primaryKey = new ItemAdditionalChargePK(entityId);
129        }
130        
131        return _primaryKey;
132    }
133    
134    private void clearHashAndString() {
135        _hashCode = null;
136        _stringValue = null;
137    }
138    
139    @Override
140    public int hashCode() {
141        if(_hashCode == null) {
142            int hashCode = 17;
143            
144            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
145            
146            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
147            hashCode = 37 * hashCode + ((itemAdditionalChargeTypePK != null) ? itemAdditionalChargeTypePK.hashCode() : 0);
148            hashCode = 37 * hashCode + ((unitOfMeasureTypePK != null) ? unitOfMeasureTypePK.hashCode() : 0);
149            hashCode = 37 * hashCode + ((minimumQuantity != null) ? minimumQuantity.hashCode() : 0);
150            hashCode = 37 * hashCode + ((maximumQuantity != null) ? maximumQuantity.hashCode() : 0);
151            hashCode = 37 * hashCode + ((currencyPK != null) ? currencyPK.hashCode() : 0);
152            hashCode = 37 * hashCode + ((unitPrice != null) ? unitPrice.hashCode() : 0);
153            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
154            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
155            
156            _hashCode = hashCode;
157        }
158        
159        return _hashCode;
160    }
161    
162    @Override
163    @Nonnull
164    public String toString() {
165        if(_stringValue == null) {
166            _stringValue = "{" + 
167                    "entityId=" + getEntityId() +
168                    ", itemPK=" + getItemPK() +
169                    ", itemAdditionalChargeTypePK=" + getItemAdditionalChargeTypePK() +
170                    ", unitOfMeasureTypePK=" + getUnitOfMeasureTypePK() +
171                    ", minimumQuantity=" + getMinimumQuantity() +
172                    ", maximumQuantity=" + getMaximumQuantity() +
173                    ", currencyPK=" + getCurrencyPK() +
174                    ", unitPrice=" + getUnitPrice() +
175                    ", fromTime=" + getFromTime() +
176                    ", thruTime=" + getThruTime() +
177                    "}";
178        }
179        return _stringValue;
180    }
181    
182    @Override
183    public boolean equals(Object other) {
184        if(this == other)
185            return true;
186        
187        if(!hasIdentity())
188            return false;
189        
190        if(other instanceof  ItemAdditionalChargeValue that) {
191            if(!that.hasIdentity())
192                return false;
193            
194            Long thisEntityId = getEntityId();
195            Long thatEntityId = that.getEntityId();
196            
197            boolean objectsEqual = thisEntityId.equals(thatEntityId);
198            if(objectsEqual)
199                objectsEqual = isIdentical(that);
200            
201            return objectsEqual;
202        } else {
203            return false;
204        }
205    }
206    
207    public boolean isIdentical(Object other) {
208        if(other instanceof ItemAdditionalChargeValue that) {
209            boolean objectsEqual = true;
210            
211            
212            if(objectsEqual) {
213                ItemPK thisItemPK = getItemPK();
214                ItemPK thatItemPK = that.getItemPK();
215                
216                if(thisItemPK == null) {
217                    objectsEqual = objectsEqual && (thatItemPK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
220                }
221            }
222            
223            if(objectsEqual) {
224                ItemAdditionalChargeTypePK thisItemAdditionalChargeTypePK = getItemAdditionalChargeTypePK();
225                ItemAdditionalChargeTypePK thatItemAdditionalChargeTypePK = that.getItemAdditionalChargeTypePK();
226                
227                if(thisItemAdditionalChargeTypePK == null) {
228                    objectsEqual = objectsEqual && (thatItemAdditionalChargeTypePK == null);
229                } else {
230                    objectsEqual = objectsEqual && thisItemAdditionalChargeTypePK.equals(thatItemAdditionalChargeTypePK);
231                }
232            }
233            
234            if(objectsEqual) {
235                UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK();
236                UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK();
237                
238                if(thisUnitOfMeasureTypePK == null) {
239                    objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null);
240                } else {
241                    objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK);
242                }
243            }
244            
245            if(objectsEqual) {
246                Long thisMinimumQuantity = getMinimumQuantity();
247                Long thatMinimumQuantity = that.getMinimumQuantity();
248                
249                if(thisMinimumQuantity == null) {
250                    objectsEqual = objectsEqual && (thatMinimumQuantity == null);
251                } else {
252                    objectsEqual = objectsEqual && thisMinimumQuantity.equals(thatMinimumQuantity);
253                }
254            }
255            
256            if(objectsEqual) {
257                Long thisMaximumQuantity = getMaximumQuantity();
258                Long thatMaximumQuantity = that.getMaximumQuantity();
259                
260                if(thisMaximumQuantity == null) {
261                    objectsEqual = objectsEqual && (thatMaximumQuantity == null);
262                } else {
263                    objectsEqual = objectsEqual && thisMaximumQuantity.equals(thatMaximumQuantity);
264                }
265            }
266            
267            if(objectsEqual) {
268                CurrencyPK thisCurrencyPK = getCurrencyPK();
269                CurrencyPK thatCurrencyPK = that.getCurrencyPK();
270                
271                if(thisCurrencyPK == null) {
272                    objectsEqual = objectsEqual && (thatCurrencyPK == null);
273                } else {
274                    objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK);
275                }
276            }
277            
278            if(objectsEqual) {
279                Long thisUnitPrice = getUnitPrice();
280                Long thatUnitPrice = that.getUnitPrice();
281                
282                if(thisUnitPrice == null) {
283                    objectsEqual = objectsEqual && (thatUnitPrice == null);
284                } else {
285                    objectsEqual = objectsEqual && thisUnitPrice.equals(thatUnitPrice);
286                }
287            }
288            
289            if(objectsEqual) {
290                Long thisFromTime = getFromTime();
291                Long thatFromTime = that.getFromTime();
292                
293                if(thisFromTime == null) {
294                    objectsEqual = objectsEqual && (thatFromTime == null);
295                } else {
296                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
297                }
298            }
299            
300            if(objectsEqual) {
301                Long thisThruTime = getThruTime();
302                Long thatThruTime = that.getThruTime();
303                
304                if(thisThruTime == null) {
305                    objectsEqual = objectsEqual && (thatThruTime == null);
306                } else {
307                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
308                }
309            }
310            
311            return objectsEqual;
312        } else {
313            return false;
314        }
315    }
316    
317    @Override
318    public boolean hasBeenModified() {
319        return itemPKHasBeenModified || itemAdditionalChargeTypePKHasBeenModified || unitOfMeasureTypePKHasBeenModified || minimumQuantityHasBeenModified || maximumQuantityHasBeenModified || currencyPKHasBeenModified || unitPriceHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
320    }
321    
322    @Override
323    public void clearHasBeenModified() {
324        itemPKHasBeenModified = false;
325        itemAdditionalChargeTypePKHasBeenModified = false;
326        unitOfMeasureTypePKHasBeenModified = false;
327        minimumQuantityHasBeenModified = false;
328        maximumQuantityHasBeenModified = false;
329        currencyPKHasBeenModified = false;
330        unitPriceHasBeenModified = false;
331        fromTimeHasBeenModified = false;
332        thruTimeHasBeenModified = false;
333    }
334    
335    @Nonnull
336    public ItemPK getItemPK() {
337        return itemPK;
338    }
339    
340    public void setItemPK(@Nonnull ItemPK itemPK)
341            throws PersistenceNotNullException {
342        checkForNull(itemPK);
343        
344        boolean update = true;
345        
346        if(this.itemPK != null) {
347            if(this.itemPK.equals(itemPK)) {
348                update = false;
349            }
350        } else if(itemPK == null) {
351            update = false;
352        }
353        
354        if(update) {
355            this.itemPK = itemPK;
356            itemPKHasBeenModified = true;
357            clearHashAndString();
358        }
359    }
360    
361    public boolean getItemPKHasBeenModified() {
362        return itemPKHasBeenModified;
363    }
364    
365    @Nonnull
366    public ItemAdditionalChargeTypePK getItemAdditionalChargeTypePK() {
367        return itemAdditionalChargeTypePK;
368    }
369    
370    public void setItemAdditionalChargeTypePK(@Nonnull ItemAdditionalChargeTypePK itemAdditionalChargeTypePK)
371            throws PersistenceNotNullException {
372        checkForNull(itemAdditionalChargeTypePK);
373        
374        boolean update = true;
375        
376        if(this.itemAdditionalChargeTypePK != null) {
377            if(this.itemAdditionalChargeTypePK.equals(itemAdditionalChargeTypePK)) {
378                update = false;
379            }
380        } else if(itemAdditionalChargeTypePK == null) {
381            update = false;
382        }
383        
384        if(update) {
385            this.itemAdditionalChargeTypePK = itemAdditionalChargeTypePK;
386            itemAdditionalChargeTypePKHasBeenModified = true;
387            clearHashAndString();
388        }
389    }
390    
391    public boolean getItemAdditionalChargeTypePKHasBeenModified() {
392        return itemAdditionalChargeTypePKHasBeenModified;
393    }
394    
395    @Nullable
396    public UnitOfMeasureTypePK getUnitOfMeasureTypePK() {
397        return unitOfMeasureTypePK;
398    }
399    
400    public void setUnitOfMeasureTypePK(@Nullable UnitOfMeasureTypePK unitOfMeasureTypePK) {
401        boolean update = true;
402        
403        if(this.unitOfMeasureTypePK != null) {
404            if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) {
405                update = false;
406            }
407        } else if(unitOfMeasureTypePK == null) {
408            update = false;
409        }
410        
411        if(update) {
412            this.unitOfMeasureTypePK = unitOfMeasureTypePK;
413            unitOfMeasureTypePKHasBeenModified = true;
414            clearHashAndString();
415        }
416    }
417    
418    public boolean getUnitOfMeasureTypePKHasBeenModified() {
419        return unitOfMeasureTypePKHasBeenModified;
420    }
421    
422    @Nullable
423    public Long getMinimumQuantity() {
424        return minimumQuantity;
425    }
426    
427    public void setMinimumQuantity(@Nullable Long minimumQuantity) {
428        boolean update = true;
429        
430        if(this.minimumQuantity != null) {
431            if(this.minimumQuantity.equals(minimumQuantity)) {
432                update = false;
433            }
434        } else if(minimumQuantity == null) {
435            update = false;
436        }
437        
438        if(update) {
439            this.minimumQuantity = minimumQuantity;
440            minimumQuantityHasBeenModified = true;
441            clearHashAndString();
442        }
443    }
444    
445    public boolean getMinimumQuantityHasBeenModified() {
446        return minimumQuantityHasBeenModified;
447    }
448    
449    @Nullable
450    public Long getMaximumQuantity() {
451        return maximumQuantity;
452    }
453    
454    public void setMaximumQuantity(@Nullable Long maximumQuantity) {
455        boolean update = true;
456        
457        if(this.maximumQuantity != null) {
458            if(this.maximumQuantity.equals(maximumQuantity)) {
459                update = false;
460            }
461        } else if(maximumQuantity == null) {
462            update = false;
463        }
464        
465        if(update) {
466            this.maximumQuantity = maximumQuantity;
467            maximumQuantityHasBeenModified = true;
468            clearHashAndString();
469        }
470    }
471    
472    public boolean getMaximumQuantityHasBeenModified() {
473        return maximumQuantityHasBeenModified;
474    }
475    
476    @Nonnull
477    public CurrencyPK getCurrencyPK() {
478        return currencyPK;
479    }
480    
481    public void setCurrencyPK(@Nonnull CurrencyPK currencyPK)
482            throws PersistenceNotNullException {
483        checkForNull(currencyPK);
484        
485        boolean update = true;
486        
487        if(this.currencyPK != null) {
488            if(this.currencyPK.equals(currencyPK)) {
489                update = false;
490            }
491        } else if(currencyPK == null) {
492            update = false;
493        }
494        
495        if(update) {
496            this.currencyPK = currencyPK;
497            currencyPKHasBeenModified = true;
498            clearHashAndString();
499        }
500    }
501    
502    public boolean getCurrencyPKHasBeenModified() {
503        return currencyPKHasBeenModified;
504    }
505    
506    @Nonnull
507    public Long getUnitPrice() {
508        return unitPrice;
509    }
510    
511    public void setUnitPrice(@Nonnull Long unitPrice)
512            throws PersistenceNotNullException {
513        checkForNull(unitPrice);
514        
515        boolean update = true;
516        
517        if(this.unitPrice != null) {
518            if(this.unitPrice.equals(unitPrice)) {
519                update = false;
520            }
521        } else if(unitPrice == null) {
522            update = false;
523        }
524        
525        if(update) {
526            this.unitPrice = unitPrice;
527            unitPriceHasBeenModified = true;
528            clearHashAndString();
529        }
530    }
531    
532    public boolean getUnitPriceHasBeenModified() {
533        return unitPriceHasBeenModified;
534    }
535    
536    @Nonnull
537    public Long getFromTime() {
538        return fromTime;
539    }
540    
541    public void setFromTime(@Nonnull Long fromTime)
542            throws PersistenceNotNullException {
543        checkForNull(fromTime);
544        
545        boolean update = true;
546        
547        if(this.fromTime != null) {
548            if(this.fromTime.equals(fromTime)) {
549                update = false;
550            }
551        } else if(fromTime == null) {
552            update = false;
553        }
554        
555        if(update) {
556            this.fromTime = fromTime;
557            fromTimeHasBeenModified = true;
558            clearHashAndString();
559        }
560    }
561    
562    public boolean getFromTimeHasBeenModified() {
563        return fromTimeHasBeenModified;
564    }
565    
566    @Nonnull
567    public Long getThruTime() {
568        return thruTime;
569    }
570    
571    public void setThruTime(@Nonnull Long thruTime)
572            throws PersistenceNotNullException {
573        checkForNull(thruTime);
574        
575        boolean update = true;
576        
577        if(this.thruTime != null) {
578            if(this.thruTime.equals(thruTime)) {
579                update = false;
580            }
581        } else if(thruTime == null) {
582            update = false;
583        }
584        
585        if(update) {
586            this.thruTime = thruTime;
587            thruTimeHasBeenModified = true;
588            clearHashAndString();
589        }
590    }
591    
592    public boolean getThruTimeHasBeenModified() {
593        return thruTimeHasBeenModified;
594    }
595    
596}