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 * 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            StringBuilder stringValue = new StringBuilder("{");
148            
149            stringValue.append("entityId=").append(getEntityId());
150            
151            stringValue.append(", itemPK=").append(getItemPK());
152            stringValue.append(", inventoryConditionPK=").append(getInventoryConditionPK());
153            stringValue.append(", unitOfMeasureTypePK=").append(getUnitOfMeasureTypePK());
154            stringValue.append(", currencyPK=").append(getCurrencyPK());
155            stringValue.append(", fromTime=").append(getFromTime());
156            stringValue.append(", thruTime=").append(getThruTime());
157            
158            stringValue.append('}');
159            
160            _stringValue = stringValue.toString();
161        }
162        return _stringValue;
163    }
164    
165    @Override
166    public boolean equals(Object other) {
167        if(this == other)
168            return true;
169        
170        if(!hasIdentity())
171            return false;
172        
173        if(other instanceof  ItemPriceValue) {
174            ItemPriceValue that = (ItemPriceValue)other;
175            
176            if(!that.hasIdentity())
177                return false;
178            
179            Long thisEntityId = getEntityId();
180            Long thatEntityId = that.getEntityId();
181            
182            boolean objectsEqual = thisEntityId.equals(thatEntityId);
183            if(objectsEqual)
184                objectsEqual = objectsEqual && isIdentical(that);
185            
186            return objectsEqual;
187        } else {
188            return false;
189        }
190    }
191    
192    public boolean isIdentical(Object other) {
193        if(other instanceof ItemPriceValue) {
194            ItemPriceValue that = (ItemPriceValue)other;
195            boolean objectsEqual = true;
196            
197            
198            if(objectsEqual) {
199                ItemPK thisItemPK = getItemPK();
200                ItemPK thatItemPK = that.getItemPK();
201                
202                if(thisItemPK == null) {
203                    objectsEqual = objectsEqual && (thatItemPK == null);
204                } else {
205                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
206                }
207            }
208            
209            if(objectsEqual) {
210                InventoryConditionPK thisInventoryConditionPK = getInventoryConditionPK();
211                InventoryConditionPK thatInventoryConditionPK = that.getInventoryConditionPK();
212                
213                if(thisInventoryConditionPK == null) {
214                    objectsEqual = objectsEqual && (thatInventoryConditionPK == null);
215                } else {
216                    objectsEqual = objectsEqual && thisInventoryConditionPK.equals(thatInventoryConditionPK);
217                }
218            }
219            
220            if(objectsEqual) {
221                UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK();
222                UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK();
223                
224                if(thisUnitOfMeasureTypePK == null) {
225                    objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null);
226                } else {
227                    objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK);
228                }
229            }
230            
231            if(objectsEqual) {
232                CurrencyPK thisCurrencyPK = getCurrencyPK();
233                CurrencyPK thatCurrencyPK = that.getCurrencyPK();
234                
235                if(thisCurrencyPK == null) {
236                    objectsEqual = objectsEqual && (thatCurrencyPK == null);
237                } else {
238                    objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK);
239                }
240            }
241            
242            if(objectsEqual) {
243                Long thisFromTime = getFromTime();
244                Long thatFromTime = that.getFromTime();
245                
246                if(thisFromTime == null) {
247                    objectsEqual = objectsEqual && (thatFromTime == null);
248                } else {
249                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
250                }
251            }
252            
253            if(objectsEqual) {
254                Long thisThruTime = getThruTime();
255                Long thatThruTime = that.getThruTime();
256                
257                if(thisThruTime == null) {
258                    objectsEqual = objectsEqual && (thatThruTime == null);
259                } else {
260                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
261                }
262            }
263            
264            return objectsEqual;
265        } else {
266            return false;
267        }
268    }
269    
270    @Override
271    public boolean hasBeenModified() {
272        return itemPKHasBeenModified || inventoryConditionPKHasBeenModified || unitOfMeasureTypePKHasBeenModified || currencyPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
273    }
274    
275    @Override
276    public void clearHasBeenModified() {
277        itemPKHasBeenModified = false;
278        inventoryConditionPKHasBeenModified = false;
279        unitOfMeasureTypePKHasBeenModified = false;
280        currencyPKHasBeenModified = false;
281        fromTimeHasBeenModified = false;
282        thruTimeHasBeenModified = false;
283    }
284    
285    public ItemPK getItemPK() {
286        return itemPK;
287    }
288    
289    public void setItemPK(ItemPK itemPK)
290            throws PersistenceNotNullException {
291        checkForNull(itemPK);
292        
293        boolean update = true;
294        
295        if(this.itemPK != null) {
296            if(this.itemPK.equals(itemPK)) {
297                update = false;
298            }
299        } else if(itemPK == null) {
300            update = false;
301        }
302        
303        if(update) {
304            this.itemPK = itemPK;
305            itemPKHasBeenModified = true;
306            clearHashAndString();
307        }
308    }
309    
310    public boolean getItemPKHasBeenModified() {
311        return itemPKHasBeenModified;
312    }
313    
314    public InventoryConditionPK getInventoryConditionPK() {
315        return inventoryConditionPK;
316    }
317    
318    public void setInventoryConditionPK(InventoryConditionPK inventoryConditionPK)
319            throws PersistenceNotNullException {
320        checkForNull(inventoryConditionPK);
321        
322        boolean update = true;
323        
324        if(this.inventoryConditionPK != null) {
325            if(this.inventoryConditionPK.equals(inventoryConditionPK)) {
326                update = false;
327            }
328        } else if(inventoryConditionPK == null) {
329            update = false;
330        }
331        
332        if(update) {
333            this.inventoryConditionPK = inventoryConditionPK;
334            inventoryConditionPKHasBeenModified = true;
335            clearHashAndString();
336        }
337    }
338    
339    public boolean getInventoryConditionPKHasBeenModified() {
340        return inventoryConditionPKHasBeenModified;
341    }
342    
343    public UnitOfMeasureTypePK getUnitOfMeasureTypePK() {
344        return unitOfMeasureTypePK;
345    }
346    
347    public void setUnitOfMeasureTypePK(UnitOfMeasureTypePK unitOfMeasureTypePK)
348            throws PersistenceNotNullException {
349        checkForNull(unitOfMeasureTypePK);
350        
351        boolean update = true;
352        
353        if(this.unitOfMeasureTypePK != null) {
354            if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) {
355                update = false;
356            }
357        } else if(unitOfMeasureTypePK == null) {
358            update = false;
359        }
360        
361        if(update) {
362            this.unitOfMeasureTypePK = unitOfMeasureTypePK;
363            unitOfMeasureTypePKHasBeenModified = true;
364            clearHashAndString();
365        }
366    }
367    
368    public boolean getUnitOfMeasureTypePKHasBeenModified() {
369        return unitOfMeasureTypePKHasBeenModified;
370    }
371    
372    public CurrencyPK getCurrencyPK() {
373        return currencyPK;
374    }
375    
376    public void setCurrencyPK(CurrencyPK currencyPK)
377            throws PersistenceNotNullException {
378        checkForNull(currencyPK);
379        
380        boolean update = true;
381        
382        if(this.currencyPK != null) {
383            if(this.currencyPK.equals(currencyPK)) {
384                update = false;
385            }
386        } else if(currencyPK == null) {
387            update = false;
388        }
389        
390        if(update) {
391            this.currencyPK = currencyPK;
392            currencyPKHasBeenModified = true;
393            clearHashAndString();
394        }
395    }
396    
397    public boolean getCurrencyPKHasBeenModified() {
398        return currencyPKHasBeenModified;
399    }
400    
401    public Long getFromTime() {
402        return fromTime;
403    }
404    
405    public void setFromTime(Long fromTime)
406            throws PersistenceNotNullException {
407        checkForNull(fromTime);
408        
409        boolean update = true;
410        
411        if(this.fromTime != null) {
412            if(this.fromTime.equals(fromTime)) {
413                update = false;
414            }
415        } else if(fromTime == null) {
416            update = false;
417        }
418        
419        if(update) {
420            this.fromTime = fromTime;
421            fromTimeHasBeenModified = true;
422            clearHashAndString();
423        }
424    }
425    
426    public boolean getFromTimeHasBeenModified() {
427        return fromTimeHasBeenModified;
428    }
429    
430    public Long getThruTime() {
431        return thruTime;
432    }
433    
434    public void setThruTime(Long thruTime)
435            throws PersistenceNotNullException {
436        checkForNull(thruTime);
437        
438        boolean update = true;
439        
440        if(this.thruTime != null) {
441            if(this.thruTime.equals(thruTime)) {
442                update = false;
443            }
444        } else if(thruTime == null) {
445            update = false;
446        }
447        
448        if(update) {
449            this.thruTime = thruTime;
450            thruTimeHasBeenModified = true;
451            clearHashAndString();
452        }
453    }
454    
455    public boolean getThruTimeHasBeenModified() {
456        return thruTimeHasBeenModified;
457    }
458    
459}