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