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