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