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