001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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 * ItemPriceValue.java
021 */
022
023package com.echothree.model.data.item.server.value;
024
025import com.echothree.model.data.item.common.pk.ItemPricePK;
026
027import com.echothree.model.data.item.server.factory.ItemPriceFactory;
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 ItemPriceValue
042        extends BaseValue<ItemPricePK>
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 fromTime;
054    private boolean fromTimeHasBeenModified = false;
055    private Long thruTime;
056    private boolean thruTimeHasBeenModified = false;
057    
058    private transient Integer _hashCode = null;
059    private transient String _stringValue = null;
060    
061    private void constructFields(ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(itemPK);
064        this.itemPK = itemPK;
065        checkForNull(inventoryConditionPK);
066        this.inventoryConditionPK = inventoryConditionPK;
067        checkForNull(unitOfMeasureTypePK);
068        this.unitOfMeasureTypePK = unitOfMeasureTypePK;
069        checkForNull(currencyPK);
070        this.currencyPK = currencyPK;
071        checkForNull(fromTime);
072        this.fromTime = fromTime;
073        checkForNull(thruTime);
074        this.thruTime = thruTime;
075    }
076    
077    /** Creates a new instance of ItemPriceValue */
078    public ItemPriceValue(ItemPricePK itemPricePK, ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super(itemPricePK);
081        constructFields(itemPK, inventoryConditionPK, unitOfMeasureTypePK, currencyPK, fromTime, thruTime);
082    }
083    
084    /** Creates a new instance of ItemPriceValue */
085    public ItemPriceValue(ItemPK itemPK, InventoryConditionPK inventoryConditionPK, UnitOfMeasureTypePK unitOfMeasureTypePK, CurrencyPK currencyPK, Long fromTime, Long thruTime)
086            throws PersistenceNotNullException {
087        super();
088        constructFields(itemPK, inventoryConditionPK, unitOfMeasureTypePK, currencyPK, fromTime, thruTime);
089    }
090    
091   @Override
092   public ItemPriceFactory getBaseFactoryInstance() {
093        return ItemPriceFactory.getInstance();
094    }
095    
096    @Override
097    public ItemPriceValue clone() {
098        Object result;
099        
100        try {
101            result = super.clone();
102        } catch (CloneNotSupportedException cnse) {
103            // This shouldn't happen, fail when it does.
104            throw new PersistenceCloneException(cnse);
105        }
106        
107        return (ItemPriceValue)result;
108    }
109    
110   @Override
111    public ItemPricePK getPrimaryKey() {
112        if(_primaryKey == null) {
113            _primaryKey = new ItemPricePK(entityId);
114        }
115        
116        return _primaryKey;
117    }
118    
119    private void clearHashAndString() {
120        _hashCode = null;
121        _stringValue = null;
122    }
123    
124    @Override
125    public int hashCode() {
126        if(_hashCode == null) {
127            int hashCode = 17;
128            
129            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
130            
131            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((inventoryConditionPK != null) ? inventoryConditionPK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((unitOfMeasureTypePK != null) ? unitOfMeasureTypePK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((currencyPK != null) ? currencyPK.hashCode() : 0);
135            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
136            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
137            
138            _hashCode = hashCode;
139        }
140        
141        return _hashCode;
142    }
143    
144    @Override
145    public String toString() {
146        if(_stringValue == null) {
147            _stringValue = "{" + 
148                    "entityId=" + getEntityId() +
149                    ", itemPK=" + getItemPK() +
150                    ", inventoryConditionPK=" + getInventoryConditionPK() +
151                    ", unitOfMeasureTypePK=" + getUnitOfMeasureTypePK() +
152                    ", currencyPK=" + getCurrencyPK() +
153                    ", fromTime=" + getFromTime() +
154                    ", thruTime=" + getThruTime() +
155                    "}";
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  ItemPriceValue that) {
169            if(!that.hasIdentity())
170                return false;
171            
172            Long thisEntityId = getEntityId();
173            Long thatEntityId = that.getEntityId();
174            
175            boolean objectsEqual = thisEntityId.equals(thatEntityId);
176            if(objectsEqual)
177                objectsEqual = isIdentical(that);
178            
179            return objectsEqual;
180        } else {
181            return false;
182        }
183    }
184    
185    public boolean isIdentical(Object other) {
186        if(other instanceof ItemPriceValue that) {
187            boolean objectsEqual = true;
188            
189            
190            if(objectsEqual) {
191                ItemPK thisItemPK = getItemPK();
192                ItemPK thatItemPK = that.getItemPK();
193                
194                if(thisItemPK == null) {
195                    objectsEqual = objectsEqual && (thatItemPK == null);
196                } else {
197                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
198                }
199            }
200            
201            if(objectsEqual) {
202                InventoryConditionPK thisInventoryConditionPK = getInventoryConditionPK();
203                InventoryConditionPK thatInventoryConditionPK = that.getInventoryConditionPK();
204                
205                if(thisInventoryConditionPK == null) {
206                    objectsEqual = objectsEqual && (thatInventoryConditionPK == null);
207                } else {
208                    objectsEqual = objectsEqual && thisInventoryConditionPK.equals(thatInventoryConditionPK);
209                }
210            }
211            
212            if(objectsEqual) {
213                UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK();
214                UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK();
215                
216                if(thisUnitOfMeasureTypePK == null) {
217                    objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK);
220                }
221            }
222            
223            if(objectsEqual) {
224                CurrencyPK thisCurrencyPK = getCurrencyPK();
225                CurrencyPK thatCurrencyPK = that.getCurrencyPK();
226                
227                if(thisCurrencyPK == null) {
228                    objectsEqual = objectsEqual && (thatCurrencyPK == null);
229                } else {
230                    objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK);
231                }
232            }
233            
234            if(objectsEqual) {
235                Long thisFromTime = getFromTime();
236                Long thatFromTime = that.getFromTime();
237                
238                if(thisFromTime == null) {
239                    objectsEqual = objectsEqual && (thatFromTime == null);
240                } else {
241                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
242                }
243            }
244            
245            if(objectsEqual) {
246                Long thisThruTime = getThruTime();
247                Long thatThruTime = that.getThruTime();
248                
249                if(thisThruTime == null) {
250                    objectsEqual = objectsEqual && (thatThruTime == null);
251                } else {
252                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
253                }
254            }
255            
256            return objectsEqual;
257        } else {
258            return false;
259        }
260    }
261    
262    @Override
263    public boolean hasBeenModified() {
264        return itemPKHasBeenModified || inventoryConditionPKHasBeenModified || unitOfMeasureTypePKHasBeenModified || currencyPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
265    }
266    
267    @Override
268    public void clearHasBeenModified() {
269        itemPKHasBeenModified = false;
270        inventoryConditionPKHasBeenModified = false;
271        unitOfMeasureTypePKHasBeenModified = false;
272        currencyPKHasBeenModified = false;
273        fromTimeHasBeenModified = false;
274        thruTimeHasBeenModified = false;
275    }
276    
277    public ItemPK getItemPK() {
278        return itemPK;
279    }
280    
281    public void setItemPK(ItemPK itemPK)
282            throws PersistenceNotNullException {
283        checkForNull(itemPK);
284        
285        boolean update = true;
286        
287        if(this.itemPK != null) {
288            if(this.itemPK.equals(itemPK)) {
289                update = false;
290            }
291        } else if(itemPK == null) {
292            update = false;
293        }
294        
295        if(update) {
296            this.itemPK = itemPK;
297            itemPKHasBeenModified = true;
298            clearHashAndString();
299        }
300    }
301    
302    public boolean getItemPKHasBeenModified() {
303        return itemPKHasBeenModified;
304    }
305    
306    public InventoryConditionPK getInventoryConditionPK() {
307        return inventoryConditionPK;
308    }
309    
310    public void setInventoryConditionPK(InventoryConditionPK inventoryConditionPK)
311            throws PersistenceNotNullException {
312        checkForNull(inventoryConditionPK);
313        
314        boolean update = true;
315        
316        if(this.inventoryConditionPK != null) {
317            if(this.inventoryConditionPK.equals(inventoryConditionPK)) {
318                update = false;
319            }
320        } else if(inventoryConditionPK == null) {
321            update = false;
322        }
323        
324        if(update) {
325            this.inventoryConditionPK = inventoryConditionPK;
326            inventoryConditionPKHasBeenModified = true;
327            clearHashAndString();
328        }
329    }
330    
331    public boolean getInventoryConditionPKHasBeenModified() {
332        return inventoryConditionPKHasBeenModified;
333    }
334    
335    public UnitOfMeasureTypePK getUnitOfMeasureTypePK() {
336        return unitOfMeasureTypePK;
337    }
338    
339    public void setUnitOfMeasureTypePK(UnitOfMeasureTypePK unitOfMeasureTypePK)
340            throws PersistenceNotNullException {
341        checkForNull(unitOfMeasureTypePK);
342        
343        boolean update = true;
344        
345        if(this.unitOfMeasureTypePK != null) {
346            if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) {
347                update = false;
348            }
349        } else if(unitOfMeasureTypePK == null) {
350            update = false;
351        }
352        
353        if(update) {
354            this.unitOfMeasureTypePK = unitOfMeasureTypePK;
355            unitOfMeasureTypePKHasBeenModified = true;
356            clearHashAndString();
357        }
358    }
359    
360    public boolean getUnitOfMeasureTypePKHasBeenModified() {
361        return unitOfMeasureTypePKHasBeenModified;
362    }
363    
364    public CurrencyPK getCurrencyPK() {
365        return currencyPK;
366    }
367    
368    public void setCurrencyPK(CurrencyPK currencyPK)
369            throws PersistenceNotNullException {
370        checkForNull(currencyPK);
371        
372        boolean update = true;
373        
374        if(this.currencyPK != null) {
375            if(this.currencyPK.equals(currencyPK)) {
376                update = false;
377            }
378        } else if(currencyPK == null) {
379            update = false;
380        }
381        
382        if(update) {
383            this.currencyPK = currencyPK;
384            currencyPKHasBeenModified = true;
385            clearHashAndString();
386        }
387    }
388    
389    public boolean getCurrencyPKHasBeenModified() {
390        return currencyPKHasBeenModified;
391    }
392    
393    public Long getFromTime() {
394        return fromTime;
395    }
396    
397    public void setFromTime(Long fromTime)
398            throws PersistenceNotNullException {
399        checkForNull(fromTime);
400        
401        boolean update = true;
402        
403        if(this.fromTime != null) {
404            if(this.fromTime.equals(fromTime)) {
405                update = false;
406            }
407        } else if(fromTime == null) {
408            update = false;
409        }
410        
411        if(update) {
412            this.fromTime = fromTime;
413            fromTimeHasBeenModified = true;
414            clearHashAndString();
415        }
416    }
417    
418    public boolean getFromTimeHasBeenModified() {
419        return fromTimeHasBeenModified;
420    }
421    
422    public Long getThruTime() {
423        return thruTime;
424    }
425    
426    public void setThruTime(Long thruTime)
427            throws PersistenceNotNullException {
428        checkForNull(thruTime);
429        
430        boolean update = true;
431        
432        if(this.thruTime != null) {
433            if(this.thruTime.equals(thruTime)) {
434                update = false;
435            }
436        } else if(thruTime == null) {
437            update = false;
438        }
439        
440        if(update) {
441            this.thruTime = thruTime;
442            thruTimeHasBeenModified = true;
443            clearHashAndString();
444        }
445    }
446    
447    public boolean getThruTimeHasBeenModified() {
448        return thruTimeHasBeenModified;
449    }
450    
451}