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 * LetterSourceDetailValue.java
021 */
022
023package com.echothree.model.data.letter.server.value;
024
025import com.echothree.model.data.letter.common.pk.LetterSourceDetailPK;
026
027import com.echothree.model.data.letter.server.factory.LetterSourceDetailFactory;
028
029import com.echothree.model.data.letter.common.pk.LetterSourcePK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.contact.common.pk.PartyContactMechanismPK;
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 LetterSourceDetailValue
041        extends BaseValue<LetterSourceDetailPK>
042        implements Cloneable, Serializable {
043    
044    private LetterSourcePK letterSourcePK;
045    private boolean letterSourcePKHasBeenModified = false;
046    private String letterSourceName;
047    private boolean letterSourceNameHasBeenModified = false;
048    private PartyPK companyPartyPK;
049    private boolean companyPartyPKHasBeenModified = false;
050    private PartyContactMechanismPK emailAddressPartyContactMechanismPK;
051    private boolean emailAddressPartyContactMechanismPKHasBeenModified = false;
052    private PartyContactMechanismPK postalAddressPartyContactMechanismPK;
053    private boolean postalAddressPartyContactMechanismPKHasBeenModified = false;
054    private PartyContactMechanismPK letterSourcePartyContactMechanismPK;
055    private boolean letterSourcePartyContactMechanismPKHasBeenModified = false;
056    private Boolean isDefault;
057    private boolean isDefaultHasBeenModified = false;
058    private Integer sortOrder;
059    private boolean sortOrderHasBeenModified = false;
060    private Long fromTime;
061    private boolean fromTimeHasBeenModified = false;
062    private Long thruTime;
063    private boolean thruTimeHasBeenModified = false;
064    
065    private transient Integer _hashCode = null;
066    private transient String _stringValue = null;
067    
068    private void constructFields(LetterSourcePK letterSourcePK, String letterSourceName, PartyPK companyPartyPK, PartyContactMechanismPK emailAddressPartyContactMechanismPK, PartyContactMechanismPK postalAddressPartyContactMechanismPK, PartyContactMechanismPK letterSourcePartyContactMechanismPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
069            throws PersistenceNotNullException {
070        checkForNull(letterSourcePK);
071        this.letterSourcePK = letterSourcePK;
072        checkForNull(letterSourceName);
073        this.letterSourceName = letterSourceName;
074        checkForNull(companyPartyPK);
075        this.companyPartyPK = companyPartyPK;
076        checkForNull(emailAddressPartyContactMechanismPK);
077        this.emailAddressPartyContactMechanismPK = emailAddressPartyContactMechanismPK;
078        checkForNull(postalAddressPartyContactMechanismPK);
079        this.postalAddressPartyContactMechanismPK = postalAddressPartyContactMechanismPK;
080        checkForNull(letterSourcePartyContactMechanismPK);
081        this.letterSourcePartyContactMechanismPK = letterSourcePartyContactMechanismPK;
082        checkForNull(isDefault);
083        this.isDefault = isDefault;
084        checkForNull(sortOrder);
085        this.sortOrder = sortOrder;
086        checkForNull(fromTime);
087        this.fromTime = fromTime;
088        checkForNull(thruTime);
089        this.thruTime = thruTime;
090    }
091    
092    /** Creates a new instance of LetterSourceDetailValue */
093    public LetterSourceDetailValue(LetterSourceDetailPK letterSourceDetailPK, LetterSourcePK letterSourcePK, String letterSourceName, PartyPK companyPartyPK, PartyContactMechanismPK emailAddressPartyContactMechanismPK, PartyContactMechanismPK postalAddressPartyContactMechanismPK, PartyContactMechanismPK letterSourcePartyContactMechanismPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
094            throws PersistenceNotNullException {
095        super(letterSourceDetailPK);
096        constructFields(letterSourcePK, letterSourceName, companyPartyPK, emailAddressPartyContactMechanismPK, postalAddressPartyContactMechanismPK, letterSourcePartyContactMechanismPK, isDefault, sortOrder, fromTime, thruTime);
097    }
098    
099    /** Creates a new instance of LetterSourceDetailValue */
100    public LetterSourceDetailValue(LetterSourcePK letterSourcePK, String letterSourceName, PartyPK companyPartyPK, PartyContactMechanismPK emailAddressPartyContactMechanismPK, PartyContactMechanismPK postalAddressPartyContactMechanismPK, PartyContactMechanismPK letterSourcePartyContactMechanismPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
101            throws PersistenceNotNullException {
102        super();
103        constructFields(letterSourcePK, letterSourceName, companyPartyPK, emailAddressPartyContactMechanismPK, postalAddressPartyContactMechanismPK, letterSourcePartyContactMechanismPK, isDefault, sortOrder, fromTime, thruTime);
104    }
105    
106   @Override
107   public LetterSourceDetailFactory getBaseFactoryInstance() {
108        return LetterSourceDetailFactory.getInstance();
109    }
110    
111    @Override
112    public LetterSourceDetailValue clone() {
113        Object result;
114        
115        try {
116            result = super.clone();
117        } catch (CloneNotSupportedException cnse) {
118            // This shouldn't happen, fail when it does.
119            throw new PersistenceCloneException(cnse);
120        }
121        
122        return (LetterSourceDetailValue)result;
123    }
124    
125   @Override
126    public LetterSourceDetailPK getPrimaryKey() {
127        if(_primaryKey == null) {
128            _primaryKey = new LetterSourceDetailPK(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 + ((letterSourcePK != null) ? letterSourcePK.hashCode() : 0);
147            hashCode = 37 * hashCode + ((letterSourceName != null) ? letterSourceName.hashCode() : 0);
148            hashCode = 37 * hashCode + ((companyPartyPK != null) ? companyPartyPK.hashCode() : 0);
149            hashCode = 37 * hashCode + ((emailAddressPartyContactMechanismPK != null) ? emailAddressPartyContactMechanismPK.hashCode() : 0);
150            hashCode = 37 * hashCode + ((postalAddressPartyContactMechanismPK != null) ? postalAddressPartyContactMechanismPK.hashCode() : 0);
151            hashCode = 37 * hashCode + ((letterSourcePartyContactMechanismPK != null) ? letterSourcePartyContactMechanismPK.hashCode() : 0);
152            hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0);
153            hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0);
154            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
155            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
156            
157            _hashCode = hashCode;
158        }
159        
160        return _hashCode;
161    }
162    
163    @Override
164    public String toString() {
165        if(_stringValue == null) {
166            _stringValue = "{" + 
167                    "entityId=" + getEntityId() +
168                    ", letterSourcePK=" + getLetterSourcePK() +
169                    ", letterSourceName=" + getLetterSourceName() +
170                    ", companyPartyPK=" + getCompanyPartyPK() +
171                    ", emailAddressPartyContactMechanismPK=" + getEmailAddressPartyContactMechanismPK() +
172                    ", postalAddressPartyContactMechanismPK=" + getPostalAddressPartyContactMechanismPK() +
173                    ", letterSourcePartyContactMechanismPK=" + getLetterSourcePartyContactMechanismPK() +
174                    ", isDefault=" + getIsDefault() +
175                    ", sortOrder=" + getSortOrder() +
176                    ", fromTime=" + getFromTime() +
177                    ", thruTime=" + getThruTime() +
178                    "}";
179        }
180        return _stringValue;
181    }
182    
183    @Override
184    public boolean equals(Object other) {
185        if(this == other)
186            return true;
187        
188        if(!hasIdentity())
189            return false;
190        
191        if(other instanceof  LetterSourceDetailValue that) {
192            if(!that.hasIdentity())
193                return false;
194            
195            Long thisEntityId = getEntityId();
196            Long thatEntityId = that.getEntityId();
197            
198            boolean objectsEqual = thisEntityId.equals(thatEntityId);
199            if(objectsEqual)
200                objectsEqual = isIdentical(that);
201            
202            return objectsEqual;
203        } else {
204            return false;
205        }
206    }
207    
208    public boolean isIdentical(Object other) {
209        if(other instanceof LetterSourceDetailValue that) {
210            boolean objectsEqual = true;
211            
212            
213            if(objectsEqual) {
214                LetterSourcePK thisLetterSourcePK = getLetterSourcePK();
215                LetterSourcePK thatLetterSourcePK = that.getLetterSourcePK();
216                
217                if(thisLetterSourcePK == null) {
218                    objectsEqual = objectsEqual && (thatLetterSourcePK == null);
219                } else {
220                    objectsEqual = objectsEqual && thisLetterSourcePK.equals(thatLetterSourcePK);
221                }
222            }
223            
224            if(objectsEqual) {
225                String thisLetterSourceName = getLetterSourceName();
226                String thatLetterSourceName = that.getLetterSourceName();
227                
228                if(thisLetterSourceName == null) {
229                    objectsEqual = objectsEqual && (thatLetterSourceName == null);
230                } else {
231                    objectsEqual = objectsEqual && thisLetterSourceName.equals(thatLetterSourceName);
232                }
233            }
234            
235            if(objectsEqual) {
236                PartyPK thisCompanyPartyPK = getCompanyPartyPK();
237                PartyPK thatCompanyPartyPK = that.getCompanyPartyPK();
238                
239                if(thisCompanyPartyPK == null) {
240                    objectsEqual = objectsEqual && (thatCompanyPartyPK == null);
241                } else {
242                    objectsEqual = objectsEqual && thisCompanyPartyPK.equals(thatCompanyPartyPK);
243                }
244            }
245            
246            if(objectsEqual) {
247                PartyContactMechanismPK thisEmailAddressPartyContactMechanismPK = getEmailAddressPartyContactMechanismPK();
248                PartyContactMechanismPK thatEmailAddressPartyContactMechanismPK = that.getEmailAddressPartyContactMechanismPK();
249                
250                if(thisEmailAddressPartyContactMechanismPK == null) {
251                    objectsEqual = objectsEqual && (thatEmailAddressPartyContactMechanismPK == null);
252                } else {
253                    objectsEqual = objectsEqual && thisEmailAddressPartyContactMechanismPK.equals(thatEmailAddressPartyContactMechanismPK);
254                }
255            }
256            
257            if(objectsEqual) {
258                PartyContactMechanismPK thisPostalAddressPartyContactMechanismPK = getPostalAddressPartyContactMechanismPK();
259                PartyContactMechanismPK thatPostalAddressPartyContactMechanismPK = that.getPostalAddressPartyContactMechanismPK();
260                
261                if(thisPostalAddressPartyContactMechanismPK == null) {
262                    objectsEqual = objectsEqual && (thatPostalAddressPartyContactMechanismPK == null);
263                } else {
264                    objectsEqual = objectsEqual && thisPostalAddressPartyContactMechanismPK.equals(thatPostalAddressPartyContactMechanismPK);
265                }
266            }
267            
268            if(objectsEqual) {
269                PartyContactMechanismPK thisLetterSourcePartyContactMechanismPK = getLetterSourcePartyContactMechanismPK();
270                PartyContactMechanismPK thatLetterSourcePartyContactMechanismPK = that.getLetterSourcePartyContactMechanismPK();
271                
272                if(thisLetterSourcePartyContactMechanismPK == null) {
273                    objectsEqual = objectsEqual && (thatLetterSourcePartyContactMechanismPK == null);
274                } else {
275                    objectsEqual = objectsEqual && thisLetterSourcePartyContactMechanismPK.equals(thatLetterSourcePartyContactMechanismPK);
276                }
277            }
278            
279            if(objectsEqual) {
280                Boolean thisIsDefault = getIsDefault();
281                Boolean thatIsDefault = that.getIsDefault();
282                
283                if(thisIsDefault == null) {
284                    objectsEqual = objectsEqual && (thatIsDefault == null);
285                } else {
286                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
287                }
288            }
289            
290            if(objectsEqual) {
291                Integer thisSortOrder = getSortOrder();
292                Integer thatSortOrder = that.getSortOrder();
293                
294                if(thisSortOrder == null) {
295                    objectsEqual = objectsEqual && (thatSortOrder == null);
296                } else {
297                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
298                }
299            }
300            
301            if(objectsEqual) {
302                Long thisFromTime = getFromTime();
303                Long thatFromTime = that.getFromTime();
304                
305                if(thisFromTime == null) {
306                    objectsEqual = objectsEqual && (thatFromTime == null);
307                } else {
308                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
309                }
310            }
311            
312            if(objectsEqual) {
313                Long thisThruTime = getThruTime();
314                Long thatThruTime = that.getThruTime();
315                
316                if(thisThruTime == null) {
317                    objectsEqual = objectsEqual && (thatThruTime == null);
318                } else {
319                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
320                }
321            }
322            
323            return objectsEqual;
324        } else {
325            return false;
326        }
327    }
328    
329    @Override
330    public boolean hasBeenModified() {
331        return letterSourcePKHasBeenModified || letterSourceNameHasBeenModified || companyPartyPKHasBeenModified || emailAddressPartyContactMechanismPKHasBeenModified || postalAddressPartyContactMechanismPKHasBeenModified || letterSourcePartyContactMechanismPKHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
332    }
333    
334    @Override
335    public void clearHasBeenModified() {
336        letterSourcePKHasBeenModified = false;
337        letterSourceNameHasBeenModified = false;
338        companyPartyPKHasBeenModified = false;
339        emailAddressPartyContactMechanismPKHasBeenModified = false;
340        postalAddressPartyContactMechanismPKHasBeenModified = false;
341        letterSourcePartyContactMechanismPKHasBeenModified = false;
342        isDefaultHasBeenModified = false;
343        sortOrderHasBeenModified = false;
344        fromTimeHasBeenModified = false;
345        thruTimeHasBeenModified = false;
346    }
347    
348    public LetterSourcePK getLetterSourcePK() {
349        return letterSourcePK;
350    }
351    
352    public void setLetterSourcePK(LetterSourcePK letterSourcePK)
353            throws PersistenceNotNullException {
354        checkForNull(letterSourcePK);
355        
356        boolean update = true;
357        
358        if(this.letterSourcePK != null) {
359            if(this.letterSourcePK.equals(letterSourcePK)) {
360                update = false;
361            }
362        } else if(letterSourcePK == null) {
363            update = false;
364        }
365        
366        if(update) {
367            this.letterSourcePK = letterSourcePK;
368            letterSourcePKHasBeenModified = true;
369            clearHashAndString();
370        }
371    }
372    
373    public boolean getLetterSourcePKHasBeenModified() {
374        return letterSourcePKHasBeenModified;
375    }
376    
377    public String getLetterSourceName() {
378        return letterSourceName;
379    }
380    
381    public void setLetterSourceName(String letterSourceName)
382            throws PersistenceNotNullException {
383        checkForNull(letterSourceName);
384        
385        boolean update = true;
386        
387        if(this.letterSourceName != null) {
388            if(this.letterSourceName.equals(letterSourceName)) {
389                update = false;
390            }
391        } else if(letterSourceName == null) {
392            update = false;
393        }
394        
395        if(update) {
396            this.letterSourceName = letterSourceName;
397            letterSourceNameHasBeenModified = true;
398            clearHashAndString();
399        }
400    }
401    
402    public boolean getLetterSourceNameHasBeenModified() {
403        return letterSourceNameHasBeenModified;
404    }
405    
406    public PartyPK getCompanyPartyPK() {
407        return companyPartyPK;
408    }
409    
410    public void setCompanyPartyPK(PartyPK companyPartyPK)
411            throws PersistenceNotNullException {
412        checkForNull(companyPartyPK);
413        
414        boolean update = true;
415        
416        if(this.companyPartyPK != null) {
417            if(this.companyPartyPK.equals(companyPartyPK)) {
418                update = false;
419            }
420        } else if(companyPartyPK == null) {
421            update = false;
422        }
423        
424        if(update) {
425            this.companyPartyPK = companyPartyPK;
426            companyPartyPKHasBeenModified = true;
427            clearHashAndString();
428        }
429    }
430    
431    public boolean getCompanyPartyPKHasBeenModified() {
432        return companyPartyPKHasBeenModified;
433    }
434    
435    public PartyContactMechanismPK getEmailAddressPartyContactMechanismPK() {
436        return emailAddressPartyContactMechanismPK;
437    }
438    
439    public void setEmailAddressPartyContactMechanismPK(PartyContactMechanismPK emailAddressPartyContactMechanismPK)
440            throws PersistenceNotNullException {
441        checkForNull(emailAddressPartyContactMechanismPK);
442        
443        boolean update = true;
444        
445        if(this.emailAddressPartyContactMechanismPK != null) {
446            if(this.emailAddressPartyContactMechanismPK.equals(emailAddressPartyContactMechanismPK)) {
447                update = false;
448            }
449        } else if(emailAddressPartyContactMechanismPK == null) {
450            update = false;
451        }
452        
453        if(update) {
454            this.emailAddressPartyContactMechanismPK = emailAddressPartyContactMechanismPK;
455            emailAddressPartyContactMechanismPKHasBeenModified = true;
456            clearHashAndString();
457        }
458    }
459    
460    public boolean getEmailAddressPartyContactMechanismPKHasBeenModified() {
461        return emailAddressPartyContactMechanismPKHasBeenModified;
462    }
463    
464    public PartyContactMechanismPK getPostalAddressPartyContactMechanismPK() {
465        return postalAddressPartyContactMechanismPK;
466    }
467    
468    public void setPostalAddressPartyContactMechanismPK(PartyContactMechanismPK postalAddressPartyContactMechanismPK)
469            throws PersistenceNotNullException {
470        checkForNull(postalAddressPartyContactMechanismPK);
471        
472        boolean update = true;
473        
474        if(this.postalAddressPartyContactMechanismPK != null) {
475            if(this.postalAddressPartyContactMechanismPK.equals(postalAddressPartyContactMechanismPK)) {
476                update = false;
477            }
478        } else if(postalAddressPartyContactMechanismPK == null) {
479            update = false;
480        }
481        
482        if(update) {
483            this.postalAddressPartyContactMechanismPK = postalAddressPartyContactMechanismPK;
484            postalAddressPartyContactMechanismPKHasBeenModified = true;
485            clearHashAndString();
486        }
487    }
488    
489    public boolean getPostalAddressPartyContactMechanismPKHasBeenModified() {
490        return postalAddressPartyContactMechanismPKHasBeenModified;
491    }
492    
493    public PartyContactMechanismPK getLetterSourcePartyContactMechanismPK() {
494        return letterSourcePartyContactMechanismPK;
495    }
496    
497    public void setLetterSourcePartyContactMechanismPK(PartyContactMechanismPK letterSourcePartyContactMechanismPK)
498            throws PersistenceNotNullException {
499        checkForNull(letterSourcePartyContactMechanismPK);
500        
501        boolean update = true;
502        
503        if(this.letterSourcePartyContactMechanismPK != null) {
504            if(this.letterSourcePartyContactMechanismPK.equals(letterSourcePartyContactMechanismPK)) {
505                update = false;
506            }
507        } else if(letterSourcePartyContactMechanismPK == null) {
508            update = false;
509        }
510        
511        if(update) {
512            this.letterSourcePartyContactMechanismPK = letterSourcePartyContactMechanismPK;
513            letterSourcePartyContactMechanismPKHasBeenModified = true;
514            clearHashAndString();
515        }
516    }
517    
518    public boolean getLetterSourcePartyContactMechanismPKHasBeenModified() {
519        return letterSourcePartyContactMechanismPKHasBeenModified;
520    }
521    
522    public Boolean getIsDefault() {
523        return isDefault;
524    }
525    
526    public void setIsDefault(Boolean isDefault)
527            throws PersistenceNotNullException {
528        checkForNull(isDefault);
529        
530        boolean update = true;
531        
532        if(this.isDefault != null) {
533            if(this.isDefault.equals(isDefault)) {
534                update = false;
535            }
536        } else if(isDefault == null) {
537            update = false;
538        }
539        
540        if(update) {
541            this.isDefault = isDefault;
542            isDefaultHasBeenModified = true;
543            clearHashAndString();
544        }
545    }
546    
547    public boolean getIsDefaultHasBeenModified() {
548        return isDefaultHasBeenModified;
549    }
550    
551    public Integer getSortOrder() {
552        return sortOrder;
553    }
554    
555    public void setSortOrder(Integer sortOrder)
556            throws PersistenceNotNullException {
557        checkForNull(sortOrder);
558        
559        boolean update = true;
560        
561        if(this.sortOrder != null) {
562            if(this.sortOrder.equals(sortOrder)) {
563                update = false;
564            }
565        } else if(sortOrder == null) {
566            update = false;
567        }
568        
569        if(update) {
570            this.sortOrder = sortOrder;
571            sortOrderHasBeenModified = true;
572            clearHashAndString();
573        }
574    }
575    
576    public boolean getSortOrderHasBeenModified() {
577        return sortOrderHasBeenModified;
578    }
579    
580    public Long getFromTime() {
581        return fromTime;
582    }
583    
584    public void setFromTime(Long fromTime)
585            throws PersistenceNotNullException {
586        checkForNull(fromTime);
587        
588        boolean update = true;
589        
590        if(this.fromTime != null) {
591            if(this.fromTime.equals(fromTime)) {
592                update = false;
593            }
594        } else if(fromTime == null) {
595            update = false;
596        }
597        
598        if(update) {
599            this.fromTime = fromTime;
600            fromTimeHasBeenModified = true;
601            clearHashAndString();
602        }
603    }
604    
605    public boolean getFromTimeHasBeenModified() {
606        return fromTimeHasBeenModified;
607    }
608    
609    public Long getThruTime() {
610        return thruTime;
611    }
612    
613    public void setThruTime(Long thruTime)
614            throws PersistenceNotNullException {
615        checkForNull(thruTime);
616        
617        boolean update = true;
618        
619        if(this.thruTime != null) {
620            if(this.thruTime.equals(thruTime)) {
621                update = false;
622            }
623        } else if(thruTime == null) {
624            update = false;
625        }
626        
627        if(update) {
628            this.thruTime = thruTime;
629            thruTimeHasBeenModified = true;
630            clearHashAndString();
631        }
632    }
633    
634    public boolean getThruTimeHasBeenModified() {
635        return thruTimeHasBeenModified;
636    }
637    
638}