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 * PeriodDetailValue.java
021 */
022
023package com.echothree.model.data.period.server.value;
024
025import com.echothree.model.data.period.common.pk.PeriodDetailPK;
026
027import com.echothree.model.data.period.server.factory.PeriodDetailFactory;
028
029import com.echothree.model.data.period.common.pk.PeriodPK;
030import com.echothree.model.data.period.common.pk.PeriodKindPK;
031import com.echothree.model.data.period.common.pk.PeriodTypePK;
032
033import com.echothree.util.common.exception.PersistenceCloneException;
034import com.echothree.util.common.exception.PersistenceNotNullException;
035
036import com.echothree.util.server.persistence.BaseValue;
037
038import java.io.Serializable;
039
040import javax.annotation.Nonnull;
041import javax.annotation.Nullable;
042
043public class PeriodDetailValue
044        extends BaseValue<PeriodDetailPK>
045        implements Cloneable, Serializable {
046    
047    private PeriodPK periodPK;
048    private boolean periodPKHasBeenModified = false;
049    private PeriodKindPK periodKindPK;
050    private boolean periodKindPKHasBeenModified = false;
051    private String periodName;
052    private boolean periodNameHasBeenModified = false;
053    private PeriodPK parentPeriodPK;
054    private boolean parentPeriodPKHasBeenModified = false;
055    private PeriodTypePK periodTypePK;
056    private boolean periodTypePKHasBeenModified = false;
057    private Long startTime;
058    private boolean startTimeHasBeenModified = false;
059    private Long endTime;
060    private boolean endTimeHasBeenModified = false;
061    private Long fromTime;
062    private boolean fromTimeHasBeenModified = false;
063    private Long thruTime;
064    private boolean thruTimeHasBeenModified = false;
065    
066    private transient Integer _hashCode = null;
067    private transient String _stringValue = null;
068    
069    private void constructFields(PeriodPK periodPK, PeriodKindPK periodKindPK, String periodName, PeriodPK parentPeriodPK, PeriodTypePK periodTypePK, Long startTime, Long endTime, Long fromTime, Long thruTime)
070            throws PersistenceNotNullException {
071        checkForNull(periodPK);
072        this.periodPK = periodPK;
073        checkForNull(periodKindPK);
074        this.periodKindPK = periodKindPK;
075        checkForNull(periodName);
076        this.periodName = periodName;
077        this.parentPeriodPK = parentPeriodPK;
078        this.periodTypePK = periodTypePK;
079        checkForNull(startTime);
080        this.startTime = startTime;
081        checkForNull(endTime);
082        this.endTime = endTime;
083        checkForNull(fromTime);
084        this.fromTime = fromTime;
085        checkForNull(thruTime);
086        this.thruTime = thruTime;
087    }
088    
089    /** Creates a new instance of PeriodDetailValue */
090    public PeriodDetailValue(PeriodDetailPK periodDetailPK, PeriodPK periodPK, PeriodKindPK periodKindPK, String periodName, PeriodPK parentPeriodPK, PeriodTypePK periodTypePK, Long startTime, Long endTime, Long fromTime, Long thruTime)
091            throws PersistenceNotNullException {
092        super(periodDetailPK);
093        constructFields(periodPK, periodKindPK, periodName, parentPeriodPK, periodTypePK, startTime, endTime, fromTime, thruTime);
094    }
095    
096    /** Creates a new instance of PeriodDetailValue */
097    public PeriodDetailValue(PeriodPK periodPK, PeriodKindPK periodKindPK, String periodName, PeriodPK parentPeriodPK, PeriodTypePK periodTypePK, Long startTime, Long endTime, Long fromTime, Long thruTime)
098            throws PersistenceNotNullException {
099        super();
100        constructFields(periodPK, periodKindPK, periodName, parentPeriodPK, periodTypePK, startTime, endTime, fromTime, thruTime);
101    }
102    
103    @Override
104    @Nonnull
105    public PeriodDetailFactory getBaseFactoryInstance() {
106        return PeriodDetailFactory.getInstance();
107    }
108    
109    @Override
110    @Nonnull
111    public PeriodDetailValue clone() {
112        Object result;
113        
114        try {
115            result = super.clone();
116        } catch (CloneNotSupportedException cnse) {
117            // This shouldn't happen, fail when it does.
118            throw new PersistenceCloneException(cnse);
119        }
120        
121        return (PeriodDetailValue)result;
122    }
123    
124    @Override
125    @Nonnull
126    public PeriodDetailPK getPrimaryKey() {
127        if(_primaryKey == null) {
128            _primaryKey = new PeriodDetailPK(entityId);
129        }
130        
131        return _primaryKey;
132    }
133    
134    private void clearHashAndString() {
135        _hashCode = null;
136        _stringValue = null;
137    }
138    
139    @Override
140    public int hashCode() {
141        if(_hashCode == null) {
142            int hashCode = 17;
143            
144            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
145            
146            hashCode = 37 * hashCode + ((periodPK != null) ? periodPK.hashCode() : 0);
147            hashCode = 37 * hashCode + ((periodKindPK != null) ? periodKindPK.hashCode() : 0);
148            hashCode = 37 * hashCode + ((periodName != null) ? periodName.hashCode() : 0);
149            hashCode = 37 * hashCode + ((parentPeriodPK != null) ? parentPeriodPK.hashCode() : 0);
150            hashCode = 37 * hashCode + ((periodTypePK != null) ? periodTypePK.hashCode() : 0);
151            hashCode = 37 * hashCode + ((startTime != null) ? startTime.hashCode() : 0);
152            hashCode = 37 * hashCode + ((endTime != null) ? endTime.hashCode() : 0);
153            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
154            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
155            
156            _hashCode = hashCode;
157        }
158        
159        return _hashCode;
160    }
161    
162    @Override
163    @Nonnull
164    public String toString() {
165        if(_stringValue == null) {
166            _stringValue = "{" + 
167                    "entityId=" + getEntityId() +
168                    ", periodPK=" + getPeriodPK() +
169                    ", periodKindPK=" + getPeriodKindPK() +
170                    ", periodName=" + getPeriodName() +
171                    ", parentPeriodPK=" + getParentPeriodPK() +
172                    ", periodTypePK=" + getPeriodTypePK() +
173                    ", startTime=" + getStartTime() +
174                    ", endTime=" + getEndTime() +
175                    ", fromTime=" + getFromTime() +
176                    ", thruTime=" + getThruTime() +
177                    "}";
178        }
179        return _stringValue;
180    }
181    
182    @Override
183    public boolean equals(Object other) {
184        if(this == other)
185            return true;
186        
187        if(!hasIdentity())
188            return false;
189        
190        if(other instanceof  PeriodDetailValue that) {
191            if(!that.hasIdentity())
192                return false;
193            
194            Long thisEntityId = getEntityId();
195            Long thatEntityId = that.getEntityId();
196            
197            boolean objectsEqual = thisEntityId.equals(thatEntityId);
198            if(objectsEqual)
199                objectsEqual = isIdentical(that);
200            
201            return objectsEqual;
202        } else {
203            return false;
204        }
205    }
206    
207    public boolean isIdentical(Object other) {
208        if(other instanceof PeriodDetailValue that) {
209            boolean objectsEqual = true;
210            
211            
212            if(objectsEqual) {
213                PeriodPK thisPeriodPK = getPeriodPK();
214                PeriodPK thatPeriodPK = that.getPeriodPK();
215                
216                if(thisPeriodPK == null) {
217                    objectsEqual = objectsEqual && (thatPeriodPK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisPeriodPK.equals(thatPeriodPK);
220                }
221            }
222            
223            if(objectsEqual) {
224                PeriodKindPK thisPeriodKindPK = getPeriodKindPK();
225                PeriodKindPK thatPeriodKindPK = that.getPeriodKindPK();
226                
227                if(thisPeriodKindPK == null) {
228                    objectsEqual = objectsEqual && (thatPeriodKindPK == null);
229                } else {
230                    objectsEqual = objectsEqual && thisPeriodKindPK.equals(thatPeriodKindPK);
231                }
232            }
233            
234            if(objectsEqual) {
235                String thisPeriodName = getPeriodName();
236                String thatPeriodName = that.getPeriodName();
237                
238                if(thisPeriodName == null) {
239                    objectsEqual = objectsEqual && (thatPeriodName == null);
240                } else {
241                    objectsEqual = objectsEqual && thisPeriodName.equals(thatPeriodName);
242                }
243            }
244            
245            if(objectsEqual) {
246                PeriodPK thisParentPeriodPK = getParentPeriodPK();
247                PeriodPK thatParentPeriodPK = that.getParentPeriodPK();
248                
249                if(thisParentPeriodPK == null) {
250                    objectsEqual = objectsEqual && (thatParentPeriodPK == null);
251                } else {
252                    objectsEqual = objectsEqual && thisParentPeriodPK.equals(thatParentPeriodPK);
253                }
254            }
255            
256            if(objectsEqual) {
257                PeriodTypePK thisPeriodTypePK = getPeriodTypePK();
258                PeriodTypePK thatPeriodTypePK = that.getPeriodTypePK();
259                
260                if(thisPeriodTypePK == null) {
261                    objectsEqual = objectsEqual && (thatPeriodTypePK == null);
262                } else {
263                    objectsEqual = objectsEqual && thisPeriodTypePK.equals(thatPeriodTypePK);
264                }
265            }
266            
267            if(objectsEqual) {
268                Long thisStartTime = getStartTime();
269                Long thatStartTime = that.getStartTime();
270                
271                if(thisStartTime == null) {
272                    objectsEqual = objectsEqual && (thatStartTime == null);
273                } else {
274                    objectsEqual = objectsEqual && thisStartTime.equals(thatStartTime);
275                }
276            }
277            
278            if(objectsEqual) {
279                Long thisEndTime = getEndTime();
280                Long thatEndTime = that.getEndTime();
281                
282                if(thisEndTime == null) {
283                    objectsEqual = objectsEqual && (thatEndTime == null);
284                } else {
285                    objectsEqual = objectsEqual && thisEndTime.equals(thatEndTime);
286                }
287            }
288            
289            if(objectsEqual) {
290                Long thisFromTime = getFromTime();
291                Long thatFromTime = that.getFromTime();
292                
293                if(thisFromTime == null) {
294                    objectsEqual = objectsEqual && (thatFromTime == null);
295                } else {
296                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
297                }
298            }
299            
300            if(objectsEqual) {
301                Long thisThruTime = getThruTime();
302                Long thatThruTime = that.getThruTime();
303                
304                if(thisThruTime == null) {
305                    objectsEqual = objectsEqual && (thatThruTime == null);
306                } else {
307                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
308                }
309            }
310            
311            return objectsEqual;
312        } else {
313            return false;
314        }
315    }
316    
317    @Override
318    public boolean hasBeenModified() {
319        return periodPKHasBeenModified || periodKindPKHasBeenModified || periodNameHasBeenModified || parentPeriodPKHasBeenModified || periodTypePKHasBeenModified || startTimeHasBeenModified || endTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
320    }
321    
322    @Override
323    public void clearHasBeenModified() {
324        periodPKHasBeenModified = false;
325        periodKindPKHasBeenModified = false;
326        periodNameHasBeenModified = false;
327        parentPeriodPKHasBeenModified = false;
328        periodTypePKHasBeenModified = false;
329        startTimeHasBeenModified = false;
330        endTimeHasBeenModified = false;
331        fromTimeHasBeenModified = false;
332        thruTimeHasBeenModified = false;
333    }
334    
335    @Nonnull
336    public PeriodPK getPeriodPK() {
337        return periodPK;
338    }
339    
340    public void setPeriodPK(@Nonnull PeriodPK periodPK)
341            throws PersistenceNotNullException {
342        checkForNull(periodPK);
343        
344        boolean update = true;
345        
346        if(this.periodPK != null) {
347            if(this.periodPK.equals(periodPK)) {
348                update = false;
349            }
350        } else if(periodPK == null) {
351            update = false;
352        }
353        
354        if(update) {
355            this.periodPK = periodPK;
356            periodPKHasBeenModified = true;
357            clearHashAndString();
358        }
359    }
360    
361    public boolean getPeriodPKHasBeenModified() {
362        return periodPKHasBeenModified;
363    }
364    
365    @Nonnull
366    public PeriodKindPK getPeriodKindPK() {
367        return periodKindPK;
368    }
369    
370    public void setPeriodKindPK(@Nonnull PeriodKindPK periodKindPK)
371            throws PersistenceNotNullException {
372        checkForNull(periodKindPK);
373        
374        boolean update = true;
375        
376        if(this.periodKindPK != null) {
377            if(this.periodKindPK.equals(periodKindPK)) {
378                update = false;
379            }
380        } else if(periodKindPK == null) {
381            update = false;
382        }
383        
384        if(update) {
385            this.periodKindPK = periodKindPK;
386            periodKindPKHasBeenModified = true;
387            clearHashAndString();
388        }
389    }
390    
391    public boolean getPeriodKindPKHasBeenModified() {
392        return periodKindPKHasBeenModified;
393    }
394    
395    @Nonnull
396    public String getPeriodName() {
397        return periodName;
398    }
399    
400    public void setPeriodName(@Nonnull String periodName)
401            throws PersistenceNotNullException {
402        checkForNull(periodName);
403        
404        boolean update = true;
405        
406        if(this.periodName != null) {
407            if(this.periodName.equals(periodName)) {
408                update = false;
409            }
410        } else if(periodName == null) {
411            update = false;
412        }
413        
414        if(update) {
415            this.periodName = periodName;
416            periodNameHasBeenModified = true;
417            clearHashAndString();
418        }
419    }
420    
421    public boolean getPeriodNameHasBeenModified() {
422        return periodNameHasBeenModified;
423    }
424    
425    @Nullable
426    public PeriodPK getParentPeriodPK() {
427        return parentPeriodPK;
428    }
429    
430    public void setParentPeriodPK(@Nullable PeriodPK parentPeriodPK) {
431        boolean update = true;
432        
433        if(this.parentPeriodPK != null) {
434            if(this.parentPeriodPK.equals(parentPeriodPK)) {
435                update = false;
436            }
437        } else if(parentPeriodPK == null) {
438            update = false;
439        }
440        
441        if(update) {
442            this.parentPeriodPK = parentPeriodPK;
443            parentPeriodPKHasBeenModified = true;
444            clearHashAndString();
445        }
446    }
447    
448    public boolean getParentPeriodPKHasBeenModified() {
449        return parentPeriodPKHasBeenModified;
450    }
451    
452    @Nullable
453    public PeriodTypePK getPeriodTypePK() {
454        return periodTypePK;
455    }
456    
457    public void setPeriodTypePK(@Nullable PeriodTypePK periodTypePK) {
458        boolean update = true;
459        
460        if(this.periodTypePK != null) {
461            if(this.periodTypePK.equals(periodTypePK)) {
462                update = false;
463            }
464        } else if(periodTypePK == null) {
465            update = false;
466        }
467        
468        if(update) {
469            this.periodTypePK = periodTypePK;
470            periodTypePKHasBeenModified = true;
471            clearHashAndString();
472        }
473    }
474    
475    public boolean getPeriodTypePKHasBeenModified() {
476        return periodTypePKHasBeenModified;
477    }
478    
479    @Nonnull
480    public Long getStartTime() {
481        return startTime;
482    }
483    
484    public void setStartTime(@Nonnull Long startTime)
485            throws PersistenceNotNullException {
486        checkForNull(startTime);
487        
488        boolean update = true;
489        
490        if(this.startTime != null) {
491            if(this.startTime.equals(startTime)) {
492                update = false;
493            }
494        } else if(startTime == null) {
495            update = false;
496        }
497        
498        if(update) {
499            this.startTime = startTime;
500            startTimeHasBeenModified = true;
501            clearHashAndString();
502        }
503    }
504    
505    public boolean getStartTimeHasBeenModified() {
506        return startTimeHasBeenModified;
507    }
508    
509    @Nonnull
510    public Long getEndTime() {
511        return endTime;
512    }
513    
514    public void setEndTime(@Nonnull Long endTime)
515            throws PersistenceNotNullException {
516        checkForNull(endTime);
517        
518        boolean update = true;
519        
520        if(this.endTime != null) {
521            if(this.endTime.equals(endTime)) {
522                update = false;
523            }
524        } else if(endTime == null) {
525            update = false;
526        }
527        
528        if(update) {
529            this.endTime = endTime;
530            endTimeHasBeenModified = true;
531            clearHashAndString();
532        }
533    }
534    
535    public boolean getEndTimeHasBeenModified() {
536        return endTimeHasBeenModified;
537    }
538    
539    @Nonnull
540    public Long getFromTime() {
541        return fromTime;
542    }
543    
544    public void setFromTime(@Nonnull Long fromTime)
545            throws PersistenceNotNullException {
546        checkForNull(fromTime);
547        
548        boolean update = true;
549        
550        if(this.fromTime != null) {
551            if(this.fromTime.equals(fromTime)) {
552                update = false;
553            }
554        } else if(fromTime == null) {
555            update = false;
556        }
557        
558        if(update) {
559            this.fromTime = fromTime;
560            fromTimeHasBeenModified = true;
561            clearHashAndString();
562        }
563    }
564    
565    public boolean getFromTimeHasBeenModified() {
566        return fromTimeHasBeenModified;
567    }
568    
569    @Nonnull
570    public Long getThruTime() {
571        return thruTime;
572    }
573    
574    public void setThruTime(@Nonnull Long thruTime)
575            throws PersistenceNotNullException {
576        checkForNull(thruTime);
577        
578        boolean update = true;
579        
580        if(this.thruTime != null) {
581            if(this.thruTime.equals(thruTime)) {
582                update = false;
583            }
584        } else if(thruTime == null) {
585            update = false;
586        }
587        
588        if(update) {
589            this.thruTime = thruTime;
590            thruTimeHasBeenModified = true;
591            clearHashAndString();
592        }
593    }
594    
595    public boolean getThruTimeHasBeenModified() {
596        return thruTimeHasBeenModified;
597    }
598    
599}