001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 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
039public class ContactMechanismDetailValue
040        extends BaseValue<ContactMechanismDetailPK>
041        implements Cloneable, Serializable {
042    
043    private ContactMechanismPK contactMechanismPK;
044    private boolean contactMechanismPKHasBeenModified = false;
045    private String contactMechanismName;
046    private boolean contactMechanismNameHasBeenModified = false;
047    private ContactMechanismTypePK contactMechanismTypePK;
048    private boolean contactMechanismTypePKHasBeenModified = false;
049    private Boolean allowSolicitation;
050    private boolean allowSolicitationHasBeenModified = false;
051    private Long fromTime;
052    private boolean fromTimeHasBeenModified = false;
053    private Long thruTime;
054    private boolean thruTimeHasBeenModified = false;
055    
056    private transient Integer _hashCode = null;
057    private transient String _stringValue = null;
058    
059    private void constructFields(ContactMechanismPK contactMechanismPK, String contactMechanismName, ContactMechanismTypePK contactMechanismTypePK, Boolean allowSolicitation, Long fromTime, Long thruTime)
060            throws PersistenceNotNullException {
061        checkForNull(contactMechanismPK);
062        this.contactMechanismPK = contactMechanismPK;
063        checkForNull(contactMechanismName);
064        this.contactMechanismName = contactMechanismName;
065        checkForNull(contactMechanismTypePK);
066        this.contactMechanismTypePK = contactMechanismTypePK;
067        checkForNull(allowSolicitation);
068        this.allowSolicitation = allowSolicitation;
069        checkForNull(fromTime);
070        this.fromTime = fromTime;
071        checkForNull(thruTime);
072        this.thruTime = thruTime;
073    }
074    
075    /** Creates a new instance of ContactMechanismDetailValue */
076    public ContactMechanismDetailValue(ContactMechanismDetailPK contactMechanismDetailPK, ContactMechanismPK contactMechanismPK, String contactMechanismName, ContactMechanismTypePK contactMechanismTypePK, Boolean allowSolicitation, Long fromTime, Long thruTime)
077            throws PersistenceNotNullException {
078        super(contactMechanismDetailPK);
079        constructFields(contactMechanismPK, contactMechanismName, contactMechanismTypePK, allowSolicitation, fromTime, thruTime);
080    }
081    
082    /** Creates a new instance of ContactMechanismDetailValue */
083    public ContactMechanismDetailValue(ContactMechanismPK contactMechanismPK, String contactMechanismName, ContactMechanismTypePK contactMechanismTypePK, Boolean allowSolicitation, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super();
086        constructFields(contactMechanismPK, contactMechanismName, contactMechanismTypePK, allowSolicitation, fromTime, thruTime);
087    }
088    
089   @Override
090   public ContactMechanismDetailFactory getBaseFactoryInstance() {
091        return ContactMechanismDetailFactory.getInstance();
092    }
093    
094    @Override
095    public ContactMechanismDetailValue clone() {
096        Object result;
097        
098        try {
099            result = super.clone();
100        } catch (CloneNotSupportedException cnse) {
101            // This shouldn't happen, fail when it does.
102            throw new PersistenceCloneException(cnse);
103        }
104        
105        return (ContactMechanismDetailValue)result;
106    }
107    
108   @Override
109    public ContactMechanismDetailPK getPrimaryKey() {
110        if(_primaryKey == null) {
111            _primaryKey = new ContactMechanismDetailPK(entityId);
112        }
113        
114        return _primaryKey;
115    }
116    
117    private void clearHashAndString() {
118        _hashCode = null;
119        _stringValue = null;
120    }
121    
122    @Override
123    public int hashCode() {
124        if(_hashCode == null) {
125            int hashCode = 17;
126            
127            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
128            
129            hashCode = 37 * hashCode + ((contactMechanismPK != null) ? contactMechanismPK.hashCode() : 0);
130            hashCode = 37 * hashCode + ((contactMechanismName != null) ? contactMechanismName.hashCode() : 0);
131            hashCode = 37 * hashCode + ((contactMechanismTypePK != null) ? contactMechanismTypePK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((allowSolicitation != null) ? allowSolicitation.hashCode() : 0);
133            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
134            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
135            
136            _hashCode = hashCode;
137        }
138        
139        return _hashCode;
140    }
141    
142    @Override
143    public String toString() {
144        if(_stringValue == null) {
145            StringBuilder stringValue = new StringBuilder("{");
146            
147            stringValue.append("entityId=").append(getEntityId());
148            
149            stringValue.append(", contactMechanismPK=").append(getContactMechanismPK());
150            stringValue.append(", contactMechanismName=").append(getContactMechanismName());
151            stringValue.append(", contactMechanismTypePK=").append(getContactMechanismTypePK());
152            stringValue.append(", allowSolicitation=").append(getAllowSolicitation());
153            stringValue.append(", fromTime=").append(getFromTime());
154            stringValue.append(", thruTime=").append(getThruTime());
155            
156            stringValue.append('}');
157            
158            _stringValue = stringValue.toString();
159        }
160        return _stringValue;
161    }
162    
163    @Override
164    public boolean equals(Object other) {
165        if(this == other)
166            return true;
167        
168        if(!hasIdentity())
169            return false;
170        
171        if(other instanceof  ContactMechanismDetailValue) {
172            ContactMechanismDetailValue that = (ContactMechanismDetailValue)other;
173            
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 = 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) {
192            ContactMechanismDetailValue that = (ContactMechanismDetailValue)other;
193            boolean objectsEqual = true;
194            
195            
196            if(objectsEqual) {
197                ContactMechanismPK thisContactMechanismPK = getContactMechanismPK();
198                ContactMechanismPK thatContactMechanismPK = that.getContactMechanismPK();
199                
200                if(thisContactMechanismPK == null) {
201                    objectsEqual = objectsEqual && (thatContactMechanismPK == null);
202                } else {
203                    objectsEqual = objectsEqual && thisContactMechanismPK.equals(thatContactMechanismPK);
204                }
205            }
206            
207            if(objectsEqual) {
208                String thisContactMechanismName = getContactMechanismName();
209                String thatContactMechanismName = that.getContactMechanismName();
210                
211                if(thisContactMechanismName == null) {
212                    objectsEqual = objectsEqual && (thatContactMechanismName == null);
213                } else {
214                    objectsEqual = objectsEqual && thisContactMechanismName.equals(thatContactMechanismName);
215                }
216            }
217            
218            if(objectsEqual) {
219                ContactMechanismTypePK thisContactMechanismTypePK = getContactMechanismTypePK();
220                ContactMechanismTypePK thatContactMechanismTypePK = that.getContactMechanismTypePK();
221                
222                if(thisContactMechanismTypePK == null) {
223                    objectsEqual = objectsEqual && (thatContactMechanismTypePK == null);
224                } else {
225                    objectsEqual = objectsEqual && thisContactMechanismTypePK.equals(thatContactMechanismTypePK);
226                }
227            }
228            
229            if(objectsEqual) {
230                Boolean thisAllowSolicitation = getAllowSolicitation();
231                Boolean thatAllowSolicitation = that.getAllowSolicitation();
232                
233                if(thisAllowSolicitation == null) {
234                    objectsEqual = objectsEqual && (thatAllowSolicitation == null);
235                } else {
236                    objectsEqual = objectsEqual && thisAllowSolicitation.equals(thatAllowSolicitation);
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 contactMechanismPKHasBeenModified || contactMechanismNameHasBeenModified || contactMechanismTypePKHasBeenModified || allowSolicitationHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
271    }
272    
273    @Override
274    public void clearHasBeenModified() {
275        contactMechanismPKHasBeenModified = false;
276        contactMechanismNameHasBeenModified = false;
277        contactMechanismTypePKHasBeenModified = false;
278        allowSolicitationHasBeenModified = false;
279        fromTimeHasBeenModified = false;
280        thruTimeHasBeenModified = false;
281    }
282    
283    public ContactMechanismPK getContactMechanismPK() {
284        return contactMechanismPK;
285    }
286    
287    public void setContactMechanismPK(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    public String getContactMechanismName() {
313        return contactMechanismName;
314    }
315    
316    public void setContactMechanismName(String contactMechanismName)
317            throws PersistenceNotNullException {
318        checkForNull(contactMechanismName);
319        
320        boolean update = true;
321        
322        if(this.contactMechanismName != null) {
323            if(this.contactMechanismName.equals(contactMechanismName)) {
324                update = false;
325            }
326        } else if(contactMechanismName == null) {
327            update = false;
328        }
329        
330        if(update) {
331            this.contactMechanismName = contactMechanismName;
332            contactMechanismNameHasBeenModified = true;
333            clearHashAndString();
334        }
335    }
336    
337    public boolean getContactMechanismNameHasBeenModified() {
338        return contactMechanismNameHasBeenModified;
339    }
340    
341    public ContactMechanismTypePK getContactMechanismTypePK() {
342        return contactMechanismTypePK;
343    }
344    
345    public void setContactMechanismTypePK(ContactMechanismTypePK contactMechanismTypePK)
346            throws PersistenceNotNullException {
347        checkForNull(contactMechanismTypePK);
348        
349        boolean update = true;
350        
351        if(this.contactMechanismTypePK != null) {
352            if(this.contactMechanismTypePK.equals(contactMechanismTypePK)) {
353                update = false;
354            }
355        } else if(contactMechanismTypePK == null) {
356            update = false;
357        }
358        
359        if(update) {
360            this.contactMechanismTypePK = contactMechanismTypePK;
361            contactMechanismTypePKHasBeenModified = true;
362            clearHashAndString();
363        }
364    }
365    
366    public boolean getContactMechanismTypePKHasBeenModified() {
367        return contactMechanismTypePKHasBeenModified;
368    }
369    
370    public Boolean getAllowSolicitation() {
371        return allowSolicitation;
372    }
373    
374    public void setAllowSolicitation(Boolean allowSolicitation)
375            throws PersistenceNotNullException {
376        checkForNull(allowSolicitation);
377        
378        boolean update = true;
379        
380        if(this.allowSolicitation != null) {
381            if(this.allowSolicitation.equals(allowSolicitation)) {
382                update = false;
383            }
384        } else if(allowSolicitation == null) {
385            update = false;
386        }
387        
388        if(update) {
389            this.allowSolicitation = allowSolicitation;
390            allowSolicitationHasBeenModified = true;
391            clearHashAndString();
392        }
393    }
394    
395    public boolean getAllowSolicitationHasBeenModified() {
396        return allowSolicitationHasBeenModified;
397    }
398    
399    public Long getFromTime() {
400        return fromTime;
401    }
402    
403    public void setFromTime(Long fromTime)
404            throws PersistenceNotNullException {
405        checkForNull(fromTime);
406        
407        boolean update = true;
408        
409        if(this.fromTime != null) {
410            if(this.fromTime.equals(fromTime)) {
411                update = false;
412            }
413        } else if(fromTime == null) {
414            update = false;
415        }
416        
417        if(update) {
418            this.fromTime = fromTime;
419            fromTimeHasBeenModified = true;
420            clearHashAndString();
421        }
422    }
423    
424    public boolean getFromTimeHasBeenModified() {
425        return fromTimeHasBeenModified;
426    }
427    
428    public Long getThruTime() {
429        return thruTime;
430    }
431    
432    public void setThruTime(Long thruTime)
433            throws PersistenceNotNullException {
434        checkForNull(thruTime);
435        
436        boolean update = true;
437        
438        if(this.thruTime != null) {
439            if(this.thruTime.equals(thruTime)) {
440                update = false;
441            }
442        } else if(thruTime == null) {
443            update = false;
444        }
445        
446        if(update) {
447            this.thruTime = thruTime;
448            thruTimeHasBeenModified = true;
449            clearHashAndString();
450        }
451    }
452    
453    public boolean getThruTimeHasBeenModified() {
454        return thruTimeHasBeenModified;
455    }
456    
457}