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 * ItemTaxClassificationDetailValue.java
021 */
022
023package com.echothree.model.data.tax.server.value;
024
025import com.echothree.model.data.tax.common.pk.ItemTaxClassificationDetailPK;
026
027import com.echothree.model.data.tax.server.factory.ItemTaxClassificationDetailFactory;
028
029import com.echothree.model.data.tax.common.pk.ItemTaxClassificationPK;
030import com.echothree.model.data.item.common.pk.ItemPK;
031import com.echothree.model.data.geo.common.pk.GeoCodePK;
032import com.echothree.model.data.tax.common.pk.TaxClassificationPK;
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 ItemTaxClassificationDetailValue
042        extends BaseValue<ItemTaxClassificationDetailPK>
043        implements Cloneable, Serializable {
044    
045    private ItemTaxClassificationPK itemTaxClassificationPK;
046    private boolean itemTaxClassificationPKHasBeenModified = false;
047    private ItemPK itemPK;
048    private boolean itemPKHasBeenModified = false;
049    private GeoCodePK countryGeoCodePK;
050    private boolean countryGeoCodePKHasBeenModified = false;
051    private TaxClassificationPK taxClassificationPK;
052    private boolean taxClassificationPKHasBeenModified = 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(ItemTaxClassificationPK itemTaxClassificationPK, ItemPK itemPK, GeoCodePK countryGeoCodePK, TaxClassificationPK taxClassificationPK, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(itemTaxClassificationPK);
064        this.itemTaxClassificationPK = itemTaxClassificationPK;
065        checkForNull(itemPK);
066        this.itemPK = itemPK;
067        checkForNull(countryGeoCodePK);
068        this.countryGeoCodePK = countryGeoCodePK;
069        checkForNull(taxClassificationPK);
070        this.taxClassificationPK = taxClassificationPK;
071        checkForNull(fromTime);
072        this.fromTime = fromTime;
073        checkForNull(thruTime);
074        this.thruTime = thruTime;
075    }
076    
077    /** Creates a new instance of ItemTaxClassificationDetailValue */
078    public ItemTaxClassificationDetailValue(ItemTaxClassificationDetailPK itemTaxClassificationDetailPK, ItemTaxClassificationPK itemTaxClassificationPK, ItemPK itemPK, GeoCodePK countryGeoCodePK, TaxClassificationPK taxClassificationPK, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super(itemTaxClassificationDetailPK);
081        constructFields(itemTaxClassificationPK, itemPK, countryGeoCodePK, taxClassificationPK, fromTime, thruTime);
082    }
083    
084    /** Creates a new instance of ItemTaxClassificationDetailValue */
085    public ItemTaxClassificationDetailValue(ItemTaxClassificationPK itemTaxClassificationPK, ItemPK itemPK, GeoCodePK countryGeoCodePK, TaxClassificationPK taxClassificationPK, Long fromTime, Long thruTime)
086            throws PersistenceNotNullException {
087        super();
088        constructFields(itemTaxClassificationPK, itemPK, countryGeoCodePK, taxClassificationPK, fromTime, thruTime);
089    }
090    
091   @Override
092   public ItemTaxClassificationDetailFactory getBaseFactoryInstance() {
093        return ItemTaxClassificationDetailFactory.getInstance();
094    }
095    
096    @Override
097    public ItemTaxClassificationDetailValue 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 (ItemTaxClassificationDetailValue)result;
108    }
109    
110   @Override
111    public ItemTaxClassificationDetailPK getPrimaryKey() {
112        if(_primaryKey == null) {
113            _primaryKey = new ItemTaxClassificationDetailPK(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 + ((itemTaxClassificationPK != null) ? itemTaxClassificationPK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((countryGeoCodePK != null) ? countryGeoCodePK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((taxClassificationPK != null) ? taxClassificationPK.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                    ", itemTaxClassificationPK=" + getItemTaxClassificationPK() +
150                    ", itemPK=" + getItemPK() +
151                    ", countryGeoCodePK=" + getCountryGeoCodePK() +
152                    ", taxClassificationPK=" + getTaxClassificationPK() +
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  ItemTaxClassificationDetailValue 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 ItemTaxClassificationDetailValue that) {
187            boolean objectsEqual = true;
188            
189            
190            if(objectsEqual) {
191                ItemTaxClassificationPK thisItemTaxClassificationPK = getItemTaxClassificationPK();
192                ItemTaxClassificationPK thatItemTaxClassificationPK = that.getItemTaxClassificationPK();
193                
194                if(thisItemTaxClassificationPK == null) {
195                    objectsEqual = objectsEqual && (thatItemTaxClassificationPK == null);
196                } else {
197                    objectsEqual = objectsEqual && thisItemTaxClassificationPK.equals(thatItemTaxClassificationPK);
198                }
199            }
200            
201            if(objectsEqual) {
202                ItemPK thisItemPK = getItemPK();
203                ItemPK thatItemPK = that.getItemPK();
204                
205                if(thisItemPK == null) {
206                    objectsEqual = objectsEqual && (thatItemPK == null);
207                } else {
208                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
209                }
210            }
211            
212            if(objectsEqual) {
213                GeoCodePK thisCountryGeoCodePK = getCountryGeoCodePK();
214                GeoCodePK thatCountryGeoCodePK = that.getCountryGeoCodePK();
215                
216                if(thisCountryGeoCodePK == null) {
217                    objectsEqual = objectsEqual && (thatCountryGeoCodePK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisCountryGeoCodePK.equals(thatCountryGeoCodePK);
220                }
221            }
222            
223            if(objectsEqual) {
224                TaxClassificationPK thisTaxClassificationPK = getTaxClassificationPK();
225                TaxClassificationPK thatTaxClassificationPK = that.getTaxClassificationPK();
226                
227                if(thisTaxClassificationPK == null) {
228                    objectsEqual = objectsEqual && (thatTaxClassificationPK == null);
229                } else {
230                    objectsEqual = objectsEqual && thisTaxClassificationPK.equals(thatTaxClassificationPK);
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 itemTaxClassificationPKHasBeenModified || itemPKHasBeenModified || countryGeoCodePKHasBeenModified || taxClassificationPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
265    }
266    
267    @Override
268    public void clearHasBeenModified() {
269        itemTaxClassificationPKHasBeenModified = false;
270        itemPKHasBeenModified = false;
271        countryGeoCodePKHasBeenModified = false;
272        taxClassificationPKHasBeenModified = false;
273        fromTimeHasBeenModified = false;
274        thruTimeHasBeenModified = false;
275    }
276    
277    public ItemTaxClassificationPK getItemTaxClassificationPK() {
278        return itemTaxClassificationPK;
279    }
280    
281    public void setItemTaxClassificationPK(ItemTaxClassificationPK itemTaxClassificationPK)
282            throws PersistenceNotNullException {
283        checkForNull(itemTaxClassificationPK);
284        
285        boolean update = true;
286        
287        if(this.itemTaxClassificationPK != null) {
288            if(this.itemTaxClassificationPK.equals(itemTaxClassificationPK)) {
289                update = false;
290            }
291        } else if(itemTaxClassificationPK == null) {
292            update = false;
293        }
294        
295        if(update) {
296            this.itemTaxClassificationPK = itemTaxClassificationPK;
297            itemTaxClassificationPKHasBeenModified = true;
298            clearHashAndString();
299        }
300    }
301    
302    public boolean getItemTaxClassificationPKHasBeenModified() {
303        return itemTaxClassificationPKHasBeenModified;
304    }
305    
306    public ItemPK getItemPK() {
307        return itemPK;
308    }
309    
310    public void setItemPK(ItemPK itemPK)
311            throws PersistenceNotNullException {
312        checkForNull(itemPK);
313        
314        boolean update = true;
315        
316        if(this.itemPK != null) {
317            if(this.itemPK.equals(itemPK)) {
318                update = false;
319            }
320        } else if(itemPK == null) {
321            update = false;
322        }
323        
324        if(update) {
325            this.itemPK = itemPK;
326            itemPKHasBeenModified = true;
327            clearHashAndString();
328        }
329    }
330    
331    public boolean getItemPKHasBeenModified() {
332        return itemPKHasBeenModified;
333    }
334    
335    public GeoCodePK getCountryGeoCodePK() {
336        return countryGeoCodePK;
337    }
338    
339    public void setCountryGeoCodePK(GeoCodePK countryGeoCodePK)
340            throws PersistenceNotNullException {
341        checkForNull(countryGeoCodePK);
342        
343        boolean update = true;
344        
345        if(this.countryGeoCodePK != null) {
346            if(this.countryGeoCodePK.equals(countryGeoCodePK)) {
347                update = false;
348            }
349        } else if(countryGeoCodePK == null) {
350            update = false;
351        }
352        
353        if(update) {
354            this.countryGeoCodePK = countryGeoCodePK;
355            countryGeoCodePKHasBeenModified = true;
356            clearHashAndString();
357        }
358    }
359    
360    public boolean getCountryGeoCodePKHasBeenModified() {
361        return countryGeoCodePKHasBeenModified;
362    }
363    
364    public TaxClassificationPK getTaxClassificationPK() {
365        return taxClassificationPK;
366    }
367    
368    public void setTaxClassificationPK(TaxClassificationPK taxClassificationPK)
369            throws PersistenceNotNullException {
370        checkForNull(taxClassificationPK);
371        
372        boolean update = true;
373        
374        if(this.taxClassificationPK != null) {
375            if(this.taxClassificationPK.equals(taxClassificationPK)) {
376                update = false;
377            }
378        } else if(taxClassificationPK == null) {
379            update = false;
380        }
381        
382        if(update) {
383            this.taxClassificationPK = taxClassificationPK;
384            taxClassificationPKHasBeenModified = true;
385            clearHashAndString();
386        }
387    }
388    
389    public boolean getTaxClassificationPKHasBeenModified() {
390        return taxClassificationPKHasBeenModified;
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}