001// --------------------------------------------------------------------------------
002// Copyright 2002-2026 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 * StandardTermValue.java
021 */
022
023package com.echothree.model.data.term.server.value;
024
025import com.echothree.model.data.term.common.pk.StandardTermPK;
026
027import com.echothree.model.data.term.server.factory.StandardTermFactory;
028
029import com.echothree.model.data.term.common.pk.TermPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038import javax.annotation.Nonnull;
039import javax.annotation.Nullable;
040
041public class StandardTermValue
042        extends BaseValue<StandardTermPK>
043        implements Cloneable, Serializable {
044    
045    private TermPK termPK;
046    private boolean termPKHasBeenModified = false;
047    private Integer netDueDays;
048    private boolean netDueDaysHasBeenModified = false;
049    private Integer discountPercentage;
050    private boolean discountPercentageHasBeenModified = false;
051    private Integer discountDays;
052    private boolean discountDaysHasBeenModified = 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(TermPK termPK, Integer netDueDays, Integer discountPercentage, Integer discountDays, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(termPK);
064        this.termPK = termPK;
065        checkForNull(netDueDays);
066        this.netDueDays = netDueDays;
067        checkForNull(discountPercentage);
068        this.discountPercentage = discountPercentage;
069        checkForNull(discountDays);
070        this.discountDays = discountDays;
071        checkForNull(fromTime);
072        this.fromTime = fromTime;
073        checkForNull(thruTime);
074        this.thruTime = thruTime;
075    }
076    
077    /** Creates a new instance of StandardTermValue */
078    public StandardTermValue(StandardTermPK standardTermPK, TermPK termPK, Integer netDueDays, Integer discountPercentage, Integer discountDays, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super(standardTermPK);
081        constructFields(termPK, netDueDays, discountPercentage, discountDays, fromTime, thruTime);
082    }
083    
084    /** Creates a new instance of StandardTermValue */
085    public StandardTermValue(TermPK termPK, Integer netDueDays, Integer discountPercentage, Integer discountDays, Long fromTime, Long thruTime)
086            throws PersistenceNotNullException {
087        super();
088        constructFields(termPK, netDueDays, discountPercentage, discountDays, fromTime, thruTime);
089    }
090    
091    @Override
092    @Nonnull
093    public StandardTermFactory getBaseFactoryInstance() {
094        return StandardTermFactory.getInstance();
095    }
096    
097    @Override
098    @Nonnull
099    public StandardTermValue clone() {
100        Object result;
101        
102        try {
103            result = super.clone();
104        } catch (CloneNotSupportedException cnse) {
105            // This shouldn't happen, fail when it does.
106            throw new PersistenceCloneException(cnse);
107        }
108        
109        return (StandardTermValue)result;
110    }
111    
112    @Override
113    @Nonnull
114    public StandardTermPK getPrimaryKey() {
115        if(_primaryKey == null) {
116            _primaryKey = new StandardTermPK(entityId);
117        }
118        
119        return _primaryKey;
120    }
121    
122    private void clearHashAndString() {
123        _hashCode = null;
124        _stringValue = null;
125    }
126    
127    @Override
128    public int hashCode() {
129        if(_hashCode == null) {
130            int hashCode = 17;
131            
132            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
133            
134            hashCode = 37 * hashCode + ((termPK != null) ? termPK.hashCode() : 0);
135            hashCode = 37 * hashCode + ((netDueDays != null) ? netDueDays.hashCode() : 0);
136            hashCode = 37 * hashCode + ((discountPercentage != null) ? discountPercentage.hashCode() : 0);
137            hashCode = 37 * hashCode + ((discountDays != null) ? discountDays.hashCode() : 0);
138            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
139            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
140            
141            _hashCode = hashCode;
142        }
143        
144        return _hashCode;
145    }
146    
147    @Override
148    @Nonnull
149    public String toString() {
150        if(_stringValue == null) {
151            _stringValue = "{" + 
152                    "entityId=" + getEntityId() +
153                    ", termPK=" + getTermPK() +
154                    ", netDueDays=" + getNetDueDays() +
155                    ", discountPercentage=" + getDiscountPercentage() +
156                    ", discountDays=" + getDiscountDays() +
157                    ", fromTime=" + getFromTime() +
158                    ", thruTime=" + getThruTime() +
159                    "}";
160        }
161        return _stringValue;
162    }
163    
164    @Override
165    public boolean equals(Object other) {
166        if(this == other)
167            return true;
168        
169        if(!hasIdentity())
170            return false;
171        
172        if(other instanceof  StandardTermValue that) {
173            if(!that.hasIdentity())
174                return false;
175            
176            Long thisEntityId = getEntityId();
177            Long thatEntityId = that.getEntityId();
178            
179            boolean objectsEqual = thisEntityId.equals(thatEntityId);
180            if(objectsEqual)
181                objectsEqual = isIdentical(that);
182            
183            return objectsEqual;
184        } else {
185            return false;
186        }
187    }
188    
189    public boolean isIdentical(Object other) {
190        if(other instanceof StandardTermValue that) {
191            boolean objectsEqual = true;
192            
193            
194            if(objectsEqual) {
195                TermPK thisTermPK = getTermPK();
196                TermPK thatTermPK = that.getTermPK();
197                
198                if(thisTermPK == null) {
199                    objectsEqual = objectsEqual && (thatTermPK == null);
200                } else {
201                    objectsEqual = objectsEqual && thisTermPK.equals(thatTermPK);
202                }
203            }
204            
205            if(objectsEqual) {
206                Integer thisNetDueDays = getNetDueDays();
207                Integer thatNetDueDays = that.getNetDueDays();
208                
209                if(thisNetDueDays == null) {
210                    objectsEqual = objectsEqual && (thatNetDueDays == null);
211                } else {
212                    objectsEqual = objectsEqual && thisNetDueDays.equals(thatNetDueDays);
213                }
214            }
215            
216            if(objectsEqual) {
217                Integer thisDiscountPercentage = getDiscountPercentage();
218                Integer thatDiscountPercentage = that.getDiscountPercentage();
219                
220                if(thisDiscountPercentage == null) {
221                    objectsEqual = objectsEqual && (thatDiscountPercentage == null);
222                } else {
223                    objectsEqual = objectsEqual && thisDiscountPercentage.equals(thatDiscountPercentage);
224                }
225            }
226            
227            if(objectsEqual) {
228                Integer thisDiscountDays = getDiscountDays();
229                Integer thatDiscountDays = that.getDiscountDays();
230                
231                if(thisDiscountDays == null) {
232                    objectsEqual = objectsEqual && (thatDiscountDays == null);
233                } else {
234                    objectsEqual = objectsEqual && thisDiscountDays.equals(thatDiscountDays);
235                }
236            }
237            
238            if(objectsEqual) {
239                Long thisFromTime = getFromTime();
240                Long thatFromTime = that.getFromTime();
241                
242                if(thisFromTime == null) {
243                    objectsEqual = objectsEqual && (thatFromTime == null);
244                } else {
245                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
246                }
247            }
248            
249            if(objectsEqual) {
250                Long thisThruTime = getThruTime();
251                Long thatThruTime = that.getThruTime();
252                
253                if(thisThruTime == null) {
254                    objectsEqual = objectsEqual && (thatThruTime == null);
255                } else {
256                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
257                }
258            }
259            
260            return objectsEqual;
261        } else {
262            return false;
263        }
264    }
265    
266    @Override
267    public boolean hasBeenModified() {
268        return termPKHasBeenModified || netDueDaysHasBeenModified || discountPercentageHasBeenModified || discountDaysHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
269    }
270    
271    @Override
272    public void clearHasBeenModified() {
273        termPKHasBeenModified = false;
274        netDueDaysHasBeenModified = false;
275        discountPercentageHasBeenModified = false;
276        discountDaysHasBeenModified = false;
277        fromTimeHasBeenModified = false;
278        thruTimeHasBeenModified = false;
279    }
280    
281    @Nonnull
282    public TermPK getTermPK() {
283        return termPK;
284    }
285    
286    public void setTermPK(@Nonnull TermPK termPK)
287            throws PersistenceNotNullException {
288        checkForNull(termPK);
289        
290        boolean update = true;
291        
292        if(this.termPK != null) {
293            if(this.termPK.equals(termPK)) {
294                update = false;
295            }
296        } else if(termPK == null) {
297            update = false;
298        }
299        
300        if(update) {
301            this.termPK = termPK;
302            termPKHasBeenModified = true;
303            clearHashAndString();
304        }
305    }
306    
307    public boolean getTermPKHasBeenModified() {
308        return termPKHasBeenModified;
309    }
310    
311    @Nonnull
312    public Integer getNetDueDays() {
313        return netDueDays;
314    }
315    
316    public void setNetDueDays(@Nonnull Integer netDueDays)
317            throws PersistenceNotNullException {
318        checkForNull(netDueDays);
319        
320        boolean update = true;
321        
322        if(this.netDueDays != null) {
323            if(this.netDueDays.equals(netDueDays)) {
324                update = false;
325            }
326        } else if(netDueDays == null) {
327            update = false;
328        }
329        
330        if(update) {
331            this.netDueDays = netDueDays;
332            netDueDaysHasBeenModified = true;
333            clearHashAndString();
334        }
335    }
336    
337    public boolean getNetDueDaysHasBeenModified() {
338        return netDueDaysHasBeenModified;
339    }
340    
341    @Nonnull
342    public Integer getDiscountPercentage() {
343        return discountPercentage;
344    }
345    
346    public void setDiscountPercentage(@Nonnull Integer discountPercentage)
347            throws PersistenceNotNullException {
348        checkForNull(discountPercentage);
349        
350        boolean update = true;
351        
352        if(this.discountPercentage != null) {
353            if(this.discountPercentage.equals(discountPercentage)) {
354                update = false;
355            }
356        } else if(discountPercentage == null) {
357            update = false;
358        }
359        
360        if(update) {
361            this.discountPercentage = discountPercentage;
362            discountPercentageHasBeenModified = true;
363            clearHashAndString();
364        }
365    }
366    
367    public boolean getDiscountPercentageHasBeenModified() {
368        return discountPercentageHasBeenModified;
369    }
370    
371    @Nonnull
372    public Integer getDiscountDays() {
373        return discountDays;
374    }
375    
376    public void setDiscountDays(@Nonnull Integer discountDays)
377            throws PersistenceNotNullException {
378        checkForNull(discountDays);
379        
380        boolean update = true;
381        
382        if(this.discountDays != null) {
383            if(this.discountDays.equals(discountDays)) {
384                update = false;
385            }
386        } else if(discountDays == null) {
387            update = false;
388        }
389        
390        if(update) {
391            this.discountDays = discountDays;
392            discountDaysHasBeenModified = true;
393            clearHashAndString();
394        }
395    }
396    
397    public boolean getDiscountDaysHasBeenModified() {
398        return discountDaysHasBeenModified;
399    }
400    
401    @Nonnull
402    public Long getFromTime() {
403        return fromTime;
404    }
405    
406    public void setFromTime(@Nonnull Long fromTime)
407            throws PersistenceNotNullException {
408        checkForNull(fromTime);
409        
410        boolean update = true;
411        
412        if(this.fromTime != null) {
413            if(this.fromTime.equals(fromTime)) {
414                update = false;
415            }
416        } else if(fromTime == null) {
417            update = false;
418        }
419        
420        if(update) {
421            this.fromTime = fromTime;
422            fromTimeHasBeenModified = true;
423            clearHashAndString();
424        }
425    }
426    
427    public boolean getFromTimeHasBeenModified() {
428        return fromTimeHasBeenModified;
429    }
430    
431    @Nonnull
432    public Long getThruTime() {
433        return thruTime;
434    }
435    
436    public void setThruTime(@Nonnull Long thruTime)
437            throws PersistenceNotNullException {
438        checkForNull(thruTime);
439        
440        boolean update = true;
441        
442        if(this.thruTime != null) {
443            if(this.thruTime.equals(thruTime)) {
444                update = false;
445            }
446        } else if(thruTime == null) {
447            update = false;
448        }
449        
450        if(update) {
451            this.thruTime = thruTime;
452            thruTimeHasBeenModified = true;
453            clearHashAndString();
454        }
455    }
456    
457    public boolean getThruTimeHasBeenModified() {
458        return thruTimeHasBeenModified;
459    }
460    
461}