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 * PartyTermValue.java
021 */
022
023package com.echothree.model.data.term.server.value;
024
025import com.echothree.model.data.term.common.pk.PartyTermPK;
026
027import com.echothree.model.data.term.server.factory.PartyTermFactory;
028
029import com.echothree.model.data.party.common.pk.PartyPK;
030import com.echothree.model.data.term.common.pk.TermPK;
031
032import com.echothree.util.common.exception.PersistenceCloneException;
033import com.echothree.util.common.exception.PersistenceNotNullException;
034
035import com.echothree.util.server.persistence.BaseValue;
036
037import java.io.Serializable;
038
039public class PartyTermValue
040        extends BaseValue<PartyTermPK>
041        implements Cloneable, Serializable {
042    
043    private PartyPK partyPK;
044    private boolean partyPKHasBeenModified = false;
045    private TermPK termPK;
046    private boolean termPKHasBeenModified = false;
047    private Boolean taxable;
048    private boolean taxableHasBeenModified = false;
049    private Long fromTime;
050    private boolean fromTimeHasBeenModified = false;
051    private Long thruTime;
052    private boolean thruTimeHasBeenModified = false;
053    
054    private transient Integer _hashCode = null;
055    private transient String _stringValue = null;
056    
057    private void constructFields(PartyPK partyPK, TermPK termPK, Boolean taxable, Long fromTime, Long thruTime)
058            throws PersistenceNotNullException {
059        checkForNull(partyPK);
060        this.partyPK = partyPK;
061        checkForNull(termPK);
062        this.termPK = termPK;
063        this.taxable = taxable;
064        checkForNull(fromTime);
065        this.fromTime = fromTime;
066        checkForNull(thruTime);
067        this.thruTime = thruTime;
068    }
069    
070    /** Creates a new instance of PartyTermValue */
071    public PartyTermValue(PartyTermPK partyTermPK, PartyPK partyPK, TermPK termPK, Boolean taxable, Long fromTime, Long thruTime)
072            throws PersistenceNotNullException {
073        super(partyTermPK);
074        constructFields(partyPK, termPK, taxable, fromTime, thruTime);
075    }
076    
077    /** Creates a new instance of PartyTermValue */
078    public PartyTermValue(PartyPK partyPK, TermPK termPK, Boolean taxable, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super();
081        constructFields(partyPK, termPK, taxable, fromTime, thruTime);
082    }
083    
084   @Override
085   public PartyTermFactory getBaseFactoryInstance() {
086        return PartyTermFactory.getInstance();
087    }
088    
089    @Override
090    public PartyTermValue clone() {
091        Object result;
092        
093        try {
094            result = super.clone();
095        } catch (CloneNotSupportedException cnse) {
096            // This shouldn't happen, fail when it does.
097            throw new PersistenceCloneException(cnse);
098        }
099        
100        return (PartyTermValue)result;
101    }
102    
103   @Override
104    public PartyTermPK getPrimaryKey() {
105        if(_primaryKey == null) {
106            _primaryKey = new PartyTermPK(entityId);
107        }
108        
109        return _primaryKey;
110    }
111    
112    private void clearHashAndString() {
113        _hashCode = null;
114        _stringValue = null;
115    }
116    
117    @Override
118    public int hashCode() {
119        if(_hashCode == null) {
120            int hashCode = 17;
121            
122            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
123            
124            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
125            hashCode = 37 * hashCode + ((termPK != null) ? termPK.hashCode() : 0);
126            hashCode = 37 * hashCode + ((taxable != null) ? taxable.hashCode() : 0);
127            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
128            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
129            
130            _hashCode = hashCode;
131        }
132        
133        return _hashCode;
134    }
135    
136    @Override
137    public String toString() {
138        if(_stringValue == null) {
139            _stringValue = "{" + 
140                    "entityId=" + getEntityId() +
141                    ", partyPK=" + getPartyPK() +
142                    ", termPK=" + getTermPK() +
143                    ", taxable=" + getTaxable() +
144                    ", fromTime=" + getFromTime() +
145                    ", thruTime=" + getThruTime() +
146                    "}";
147        }
148        return _stringValue;
149    }
150    
151    @Override
152    public boolean equals(Object other) {
153        if(this == other)
154            return true;
155        
156        if(!hasIdentity())
157            return false;
158        
159        if(other instanceof  PartyTermValue that) {
160            if(!that.hasIdentity())
161                return false;
162            
163            Long thisEntityId = getEntityId();
164            Long thatEntityId = that.getEntityId();
165            
166            boolean objectsEqual = thisEntityId.equals(thatEntityId);
167            if(objectsEqual)
168                objectsEqual = isIdentical(that);
169            
170            return objectsEqual;
171        } else {
172            return false;
173        }
174    }
175    
176    public boolean isIdentical(Object other) {
177        if(other instanceof PartyTermValue that) {
178            boolean objectsEqual = true;
179            
180            
181            if(objectsEqual) {
182                PartyPK thisPartyPK = getPartyPK();
183                PartyPK thatPartyPK = that.getPartyPK();
184                
185                if(thisPartyPK == null) {
186                    objectsEqual = objectsEqual && (thatPartyPK == null);
187                } else {
188                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
189                }
190            }
191            
192            if(objectsEqual) {
193                TermPK thisTermPK = getTermPK();
194                TermPK thatTermPK = that.getTermPK();
195                
196                if(thisTermPK == null) {
197                    objectsEqual = objectsEqual && (thatTermPK == null);
198                } else {
199                    objectsEqual = objectsEqual && thisTermPK.equals(thatTermPK);
200                }
201            }
202            
203            if(objectsEqual) {
204                Boolean thisTaxable = getTaxable();
205                Boolean thatTaxable = that.getTaxable();
206                
207                if(thisTaxable == null) {
208                    objectsEqual = objectsEqual && (thatTaxable == null);
209                } else {
210                    objectsEqual = objectsEqual && thisTaxable.equals(thatTaxable);
211                }
212            }
213            
214            if(objectsEqual) {
215                Long thisFromTime = getFromTime();
216                Long thatFromTime = that.getFromTime();
217                
218                if(thisFromTime == null) {
219                    objectsEqual = objectsEqual && (thatFromTime == null);
220                } else {
221                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
222                }
223            }
224            
225            if(objectsEqual) {
226                Long thisThruTime = getThruTime();
227                Long thatThruTime = that.getThruTime();
228                
229                if(thisThruTime == null) {
230                    objectsEqual = objectsEqual && (thatThruTime == null);
231                } else {
232                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
233                }
234            }
235            
236            return objectsEqual;
237        } else {
238            return false;
239        }
240    }
241    
242    @Override
243    public boolean hasBeenModified() {
244        return partyPKHasBeenModified || termPKHasBeenModified || taxableHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
245    }
246    
247    @Override
248    public void clearHasBeenModified() {
249        partyPKHasBeenModified = false;
250        termPKHasBeenModified = false;
251        taxableHasBeenModified = false;
252        fromTimeHasBeenModified = false;
253        thruTimeHasBeenModified = false;
254    }
255    
256    public PartyPK getPartyPK() {
257        return partyPK;
258    }
259    
260    public void setPartyPK(PartyPK partyPK)
261            throws PersistenceNotNullException {
262        checkForNull(partyPK);
263        
264        boolean update = true;
265        
266        if(this.partyPK != null) {
267            if(this.partyPK.equals(partyPK)) {
268                update = false;
269            }
270        } else if(partyPK == null) {
271            update = false;
272        }
273        
274        if(update) {
275            this.partyPK = partyPK;
276            partyPKHasBeenModified = true;
277            clearHashAndString();
278        }
279    }
280    
281    public boolean getPartyPKHasBeenModified() {
282        return partyPKHasBeenModified;
283    }
284    
285    public TermPK getTermPK() {
286        return termPK;
287    }
288    
289    public void setTermPK(TermPK termPK)
290            throws PersistenceNotNullException {
291        checkForNull(termPK);
292        
293        boolean update = true;
294        
295        if(this.termPK != null) {
296            if(this.termPK.equals(termPK)) {
297                update = false;
298            }
299        } else if(termPK == null) {
300            update = false;
301        }
302        
303        if(update) {
304            this.termPK = termPK;
305            termPKHasBeenModified = true;
306            clearHashAndString();
307        }
308    }
309    
310    public boolean getTermPKHasBeenModified() {
311        return termPKHasBeenModified;
312    }
313    
314    public Boolean getTaxable() {
315        return taxable;
316    }
317    
318    public void setTaxable(Boolean taxable) {
319        boolean update = true;
320        
321        if(this.taxable != null) {
322            if(this.taxable.equals(taxable)) {
323                update = false;
324            }
325        } else if(taxable == null) {
326            update = false;
327        }
328        
329        if(update) {
330            this.taxable = taxable;
331            taxableHasBeenModified = true;
332            clearHashAndString();
333        }
334    }
335    
336    public boolean getTaxableHasBeenModified() {
337        return taxableHasBeenModified;
338    }
339    
340    public Long getFromTime() {
341        return fromTime;
342    }
343    
344    public void setFromTime(Long fromTime)
345            throws PersistenceNotNullException {
346        checkForNull(fromTime);
347        
348        boolean update = true;
349        
350        if(this.fromTime != null) {
351            if(this.fromTime.equals(fromTime)) {
352                update = false;
353            }
354        } else if(fromTime == null) {
355            update = false;
356        }
357        
358        if(update) {
359            this.fromTime = fromTime;
360            fromTimeHasBeenModified = true;
361            clearHashAndString();
362        }
363    }
364    
365    public boolean getFromTimeHasBeenModified() {
366        return fromTimeHasBeenModified;
367    }
368    
369    public Long getThruTime() {
370        return thruTime;
371    }
372    
373    public void setThruTime(Long thruTime)
374            throws PersistenceNotNullException {
375        checkForNull(thruTime);
376        
377        boolean update = true;
378        
379        if(this.thruTime != null) {
380            if(this.thruTime.equals(thruTime)) {
381                update = false;
382            }
383        } else if(thruTime == null) {
384            update = false;
385        }
386        
387        if(update) {
388            this.thruTime = thruTime;
389            thruTimeHasBeenModified = true;
390            clearHashAndString();
391        }
392    }
393    
394    public boolean getThruTimeHasBeenModified() {
395        return thruTimeHasBeenModified;
396    }
397    
398}