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