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