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