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 * PostalAddressLineElementValue.java
021 */
022
023package com.echothree.model.data.contact.server.value;
024
025import com.echothree.model.data.contact.common.pk.PostalAddressLineElementPK;
026
027import com.echothree.model.data.contact.server.factory.PostalAddressLineElementFactory;
028
029import com.echothree.model.data.contact.common.pk.PostalAddressLinePK;
030import com.echothree.model.data.contact.common.pk.PostalAddressElementTypePK;
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 PostalAddressLineElementValue
040        extends BaseValue<PostalAddressLineElementPK>
041        implements Cloneable, Serializable {
042    
043    private PostalAddressLinePK postalAddressLinePK;
044    private boolean postalAddressLinePKHasBeenModified = false;
045    private Integer postalAddressLineElementSortOrder;
046    private boolean postalAddressLineElementSortOrderHasBeenModified = false;
047    private PostalAddressElementTypePK postalAddressElementTypePK;
048    private boolean postalAddressElementTypePKHasBeenModified = false;
049    private String prefix;
050    private boolean prefixHasBeenModified = false;
051    private Boolean alwaysIncludePrefix;
052    private boolean alwaysIncludePrefixHasBeenModified = false;
053    private String suffix;
054    private boolean suffixHasBeenModified = false;
055    private Boolean alwaysIncludeSuffix;
056    private boolean alwaysIncludeSuffixHasBeenModified = false;
057    private Long fromTime;
058    private boolean fromTimeHasBeenModified = false;
059    private Long thruTime;
060    private boolean thruTimeHasBeenModified = false;
061    
062    private transient Integer _hashCode = null;
063    private transient String _stringValue = null;
064    
065    private void constructFields(PostalAddressLinePK postalAddressLinePK, Integer postalAddressLineElementSortOrder, PostalAddressElementTypePK postalAddressElementTypePK, String prefix, Boolean alwaysIncludePrefix, String suffix, Boolean alwaysIncludeSuffix, Long fromTime, Long thruTime)
066            throws PersistenceNotNullException {
067        checkForNull(postalAddressLinePK);
068        this.postalAddressLinePK = postalAddressLinePK;
069        checkForNull(postalAddressLineElementSortOrder);
070        this.postalAddressLineElementSortOrder = postalAddressLineElementSortOrder;
071        checkForNull(postalAddressElementTypePK);
072        this.postalAddressElementTypePK = postalAddressElementTypePK;
073        this.prefix = prefix;
074        checkForNull(alwaysIncludePrefix);
075        this.alwaysIncludePrefix = alwaysIncludePrefix;
076        this.suffix = suffix;
077        checkForNull(alwaysIncludeSuffix);
078        this.alwaysIncludeSuffix = alwaysIncludeSuffix;
079        checkForNull(fromTime);
080        this.fromTime = fromTime;
081        checkForNull(thruTime);
082        this.thruTime = thruTime;
083    }
084    
085    /** Creates a new instance of PostalAddressLineElementValue */
086    public PostalAddressLineElementValue(PostalAddressLineElementPK postalAddressLineElementPK, PostalAddressLinePK postalAddressLinePK, Integer postalAddressLineElementSortOrder, PostalAddressElementTypePK postalAddressElementTypePK, String prefix, Boolean alwaysIncludePrefix, String suffix, Boolean alwaysIncludeSuffix, Long fromTime, Long thruTime)
087            throws PersistenceNotNullException {
088        super(postalAddressLineElementPK);
089        constructFields(postalAddressLinePK, postalAddressLineElementSortOrder, postalAddressElementTypePK, prefix, alwaysIncludePrefix, suffix, alwaysIncludeSuffix, fromTime, thruTime);
090    }
091    
092    /** Creates a new instance of PostalAddressLineElementValue */
093    public PostalAddressLineElementValue(PostalAddressLinePK postalAddressLinePK, Integer postalAddressLineElementSortOrder, PostalAddressElementTypePK postalAddressElementTypePK, String prefix, Boolean alwaysIncludePrefix, String suffix, Boolean alwaysIncludeSuffix, Long fromTime, Long thruTime)
094            throws PersistenceNotNullException {
095        super();
096        constructFields(postalAddressLinePK, postalAddressLineElementSortOrder, postalAddressElementTypePK, prefix, alwaysIncludePrefix, suffix, alwaysIncludeSuffix, fromTime, thruTime);
097    }
098    
099   @Override
100   public PostalAddressLineElementFactory getBaseFactoryInstance() {
101        return PostalAddressLineElementFactory.getInstance();
102    }
103    
104    @Override
105    public PostalAddressLineElementValue clone() {
106        Object result;
107        
108        try {
109            result = super.clone();
110        } catch (CloneNotSupportedException cnse) {
111            // This shouldn't happen, fail when it does.
112            throw new PersistenceCloneException(cnse);
113        }
114        
115        return (PostalAddressLineElementValue)result;
116    }
117    
118   @Override
119    public PostalAddressLineElementPK getPrimaryKey() {
120        if(_primaryKey == null) {
121            _primaryKey = new PostalAddressLineElementPK(entityId);
122        }
123        
124        return _primaryKey;
125    }
126    
127    private void clearHashAndString() {
128        _hashCode = null;
129        _stringValue = null;
130    }
131    
132    @Override
133    public int hashCode() {
134        if(_hashCode == null) {
135            int hashCode = 17;
136            
137            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
138            
139            hashCode = 37 * hashCode + ((postalAddressLinePK != null) ? postalAddressLinePK.hashCode() : 0);
140            hashCode = 37 * hashCode + ((postalAddressLineElementSortOrder != null) ? postalAddressLineElementSortOrder.hashCode() : 0);
141            hashCode = 37 * hashCode + ((postalAddressElementTypePK != null) ? postalAddressElementTypePK.hashCode() : 0);
142            hashCode = 37 * hashCode + ((prefix != null) ? prefix.hashCode() : 0);
143            hashCode = 37 * hashCode + ((alwaysIncludePrefix != null) ? alwaysIncludePrefix.hashCode() : 0);
144            hashCode = 37 * hashCode + ((suffix != null) ? suffix.hashCode() : 0);
145            hashCode = 37 * hashCode + ((alwaysIncludeSuffix != null) ? alwaysIncludeSuffix.hashCode() : 0);
146            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
147            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
148            
149            _hashCode = hashCode;
150        }
151        
152        return _hashCode;
153    }
154    
155    @Override
156    public String toString() {
157        if(_stringValue == null) {
158            StringBuilder stringValue = new StringBuilder("{");
159            
160            stringValue.append("entityId=").append(getEntityId());
161            
162            stringValue.append(", postalAddressLinePK=").append(getPostalAddressLinePK());
163            stringValue.append(", postalAddressLineElementSortOrder=").append(getPostalAddressLineElementSortOrder());
164            stringValue.append(", postalAddressElementTypePK=").append(getPostalAddressElementTypePK());
165            stringValue.append(", prefix=").append(getPrefix());
166            stringValue.append(", alwaysIncludePrefix=").append(getAlwaysIncludePrefix());
167            stringValue.append(", suffix=").append(getSuffix());
168            stringValue.append(", alwaysIncludeSuffix=").append(getAlwaysIncludeSuffix());
169            stringValue.append(", fromTime=").append(getFromTime());
170            stringValue.append(", thruTime=").append(getThruTime());
171            
172            stringValue.append('}');
173            
174            _stringValue = stringValue.toString();
175        }
176        return _stringValue;
177    }
178    
179    @Override
180    public boolean equals(Object other) {
181        if(this == other)
182            return true;
183        
184        if(!hasIdentity())
185            return false;
186        
187        if(other instanceof  PostalAddressLineElementValue) {
188            PostalAddressLineElementValue that = (PostalAddressLineElementValue)other;
189            
190            if(!that.hasIdentity())
191                return false;
192            
193            Long thisEntityId = getEntityId();
194            Long thatEntityId = that.getEntityId();
195            
196            boolean objectsEqual = thisEntityId.equals(thatEntityId);
197            if(objectsEqual)
198                objectsEqual = objectsEqual && isIdentical(that);
199            
200            return objectsEqual;
201        } else {
202            return false;
203        }
204    }
205    
206    public boolean isIdentical(Object other) {
207        if(other instanceof PostalAddressLineElementValue) {
208            PostalAddressLineElementValue that = (PostalAddressLineElementValue)other;
209            boolean objectsEqual = true;
210            
211            
212            if(objectsEqual) {
213                PostalAddressLinePK thisPostalAddressLinePK = getPostalAddressLinePK();
214                PostalAddressLinePK thatPostalAddressLinePK = that.getPostalAddressLinePK();
215                
216                if(thisPostalAddressLinePK == null) {
217                    objectsEqual = objectsEqual && (thatPostalAddressLinePK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisPostalAddressLinePK.equals(thatPostalAddressLinePK);
220                }
221            }
222            
223            if(objectsEqual) {
224                Integer thisPostalAddressLineElementSortOrder = getPostalAddressLineElementSortOrder();
225                Integer thatPostalAddressLineElementSortOrder = that.getPostalAddressLineElementSortOrder();
226                
227                if(thisPostalAddressLineElementSortOrder == null) {
228                    objectsEqual = objectsEqual && (thatPostalAddressLineElementSortOrder == null);
229                } else {
230                    objectsEqual = objectsEqual && thisPostalAddressLineElementSortOrder.equals(thatPostalAddressLineElementSortOrder);
231                }
232            }
233            
234            if(objectsEqual) {
235                PostalAddressElementTypePK thisPostalAddressElementTypePK = getPostalAddressElementTypePK();
236                PostalAddressElementTypePK thatPostalAddressElementTypePK = that.getPostalAddressElementTypePK();
237                
238                if(thisPostalAddressElementTypePK == null) {
239                    objectsEqual = objectsEqual && (thatPostalAddressElementTypePK == null);
240                } else {
241                    objectsEqual = objectsEqual && thisPostalAddressElementTypePK.equals(thatPostalAddressElementTypePK);
242                }
243            }
244            
245            if(objectsEqual) {
246                String thisPrefix = getPrefix();
247                String thatPrefix = that.getPrefix();
248                
249                if(thisPrefix == null) {
250                    objectsEqual = objectsEqual && (thatPrefix == null);
251                } else {
252                    objectsEqual = objectsEqual && thisPrefix.equals(thatPrefix);
253                }
254            }
255            
256            if(objectsEqual) {
257                Boolean thisAlwaysIncludePrefix = getAlwaysIncludePrefix();
258                Boolean thatAlwaysIncludePrefix = that.getAlwaysIncludePrefix();
259                
260                if(thisAlwaysIncludePrefix == null) {
261                    objectsEqual = objectsEqual && (thatAlwaysIncludePrefix == null);
262                } else {
263                    objectsEqual = objectsEqual && thisAlwaysIncludePrefix.equals(thatAlwaysIncludePrefix);
264                }
265            }
266            
267            if(objectsEqual) {
268                String thisSuffix = getSuffix();
269                String thatSuffix = that.getSuffix();
270                
271                if(thisSuffix == null) {
272                    objectsEqual = objectsEqual && (thatSuffix == null);
273                } else {
274                    objectsEqual = objectsEqual && thisSuffix.equals(thatSuffix);
275                }
276            }
277            
278            if(objectsEqual) {
279                Boolean thisAlwaysIncludeSuffix = getAlwaysIncludeSuffix();
280                Boolean thatAlwaysIncludeSuffix = that.getAlwaysIncludeSuffix();
281                
282                if(thisAlwaysIncludeSuffix == null) {
283                    objectsEqual = objectsEqual && (thatAlwaysIncludeSuffix == null);
284                } else {
285                    objectsEqual = objectsEqual && thisAlwaysIncludeSuffix.equals(thatAlwaysIncludeSuffix);
286                }
287            }
288            
289            if(objectsEqual) {
290                Long thisFromTime = getFromTime();
291                Long thatFromTime = that.getFromTime();
292                
293                if(thisFromTime == null) {
294                    objectsEqual = objectsEqual && (thatFromTime == null);
295                } else {
296                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
297                }
298            }
299            
300            if(objectsEqual) {
301                Long thisThruTime = getThruTime();
302                Long thatThruTime = that.getThruTime();
303                
304                if(thisThruTime == null) {
305                    objectsEqual = objectsEqual && (thatThruTime == null);
306                } else {
307                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
308                }
309            }
310            
311            return objectsEqual;
312        } else {
313            return false;
314        }
315    }
316    
317    @Override
318    public boolean hasBeenModified() {
319        return postalAddressLinePKHasBeenModified || postalAddressLineElementSortOrderHasBeenModified || postalAddressElementTypePKHasBeenModified || prefixHasBeenModified || alwaysIncludePrefixHasBeenModified || suffixHasBeenModified || alwaysIncludeSuffixHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
320    }
321    
322    @Override
323    public void clearHasBeenModified() {
324        postalAddressLinePKHasBeenModified = false;
325        postalAddressLineElementSortOrderHasBeenModified = false;
326        postalAddressElementTypePKHasBeenModified = false;
327        prefixHasBeenModified = false;
328        alwaysIncludePrefixHasBeenModified = false;
329        suffixHasBeenModified = false;
330        alwaysIncludeSuffixHasBeenModified = false;
331        fromTimeHasBeenModified = false;
332        thruTimeHasBeenModified = false;
333    }
334    
335    public PostalAddressLinePK getPostalAddressLinePK() {
336        return postalAddressLinePK;
337    }
338    
339    public void setPostalAddressLinePK(PostalAddressLinePK postalAddressLinePK)
340            throws PersistenceNotNullException {
341        checkForNull(postalAddressLinePK);
342        
343        boolean update = true;
344        
345        if(this.postalAddressLinePK != null) {
346            if(this.postalAddressLinePK.equals(postalAddressLinePK)) {
347                update = false;
348            }
349        } else if(postalAddressLinePK == null) {
350            update = false;
351        }
352        
353        if(update) {
354            this.postalAddressLinePK = postalAddressLinePK;
355            postalAddressLinePKHasBeenModified = true;
356            clearHashAndString();
357        }
358    }
359    
360    public boolean getPostalAddressLinePKHasBeenModified() {
361        return postalAddressLinePKHasBeenModified;
362    }
363    
364    public Integer getPostalAddressLineElementSortOrder() {
365        return postalAddressLineElementSortOrder;
366    }
367    
368    public void setPostalAddressLineElementSortOrder(Integer postalAddressLineElementSortOrder)
369            throws PersistenceNotNullException {
370        checkForNull(postalAddressLineElementSortOrder);
371        
372        boolean update = true;
373        
374        if(this.postalAddressLineElementSortOrder != null) {
375            if(this.postalAddressLineElementSortOrder.equals(postalAddressLineElementSortOrder)) {
376                update = false;
377            }
378        } else if(postalAddressLineElementSortOrder == null) {
379            update = false;
380        }
381        
382        if(update) {
383            this.postalAddressLineElementSortOrder = postalAddressLineElementSortOrder;
384            postalAddressLineElementSortOrderHasBeenModified = true;
385            clearHashAndString();
386        }
387    }
388    
389    public boolean getPostalAddressLineElementSortOrderHasBeenModified() {
390        return postalAddressLineElementSortOrderHasBeenModified;
391    }
392    
393    public PostalAddressElementTypePK getPostalAddressElementTypePK() {
394        return postalAddressElementTypePK;
395    }
396    
397    public void setPostalAddressElementTypePK(PostalAddressElementTypePK postalAddressElementTypePK)
398            throws PersistenceNotNullException {
399        checkForNull(postalAddressElementTypePK);
400        
401        boolean update = true;
402        
403        if(this.postalAddressElementTypePK != null) {
404            if(this.postalAddressElementTypePK.equals(postalAddressElementTypePK)) {
405                update = false;
406            }
407        } else if(postalAddressElementTypePK == null) {
408            update = false;
409        }
410        
411        if(update) {
412            this.postalAddressElementTypePK = postalAddressElementTypePK;
413            postalAddressElementTypePKHasBeenModified = true;
414            clearHashAndString();
415        }
416    }
417    
418    public boolean getPostalAddressElementTypePKHasBeenModified() {
419        return postalAddressElementTypePKHasBeenModified;
420    }
421    
422    public String getPrefix() {
423        return prefix;
424    }
425    
426    public void setPrefix(String prefix) {
427        boolean update = true;
428        
429        if(this.prefix != null) {
430            if(this.prefix.equals(prefix)) {
431                update = false;
432            }
433        } else if(prefix == null) {
434            update = false;
435        }
436        
437        if(update) {
438            this.prefix = prefix;
439            prefixHasBeenModified = true;
440            clearHashAndString();
441        }
442    }
443    
444    public boolean getPrefixHasBeenModified() {
445        return prefixHasBeenModified;
446    }
447    
448    public Boolean getAlwaysIncludePrefix() {
449        return alwaysIncludePrefix;
450    }
451    
452    public void setAlwaysIncludePrefix(Boolean alwaysIncludePrefix)
453            throws PersistenceNotNullException {
454        checkForNull(alwaysIncludePrefix);
455        
456        boolean update = true;
457        
458        if(this.alwaysIncludePrefix != null) {
459            if(this.alwaysIncludePrefix.equals(alwaysIncludePrefix)) {
460                update = false;
461            }
462        } else if(alwaysIncludePrefix == null) {
463            update = false;
464        }
465        
466        if(update) {
467            this.alwaysIncludePrefix = alwaysIncludePrefix;
468            alwaysIncludePrefixHasBeenModified = true;
469            clearHashAndString();
470        }
471    }
472    
473    public boolean getAlwaysIncludePrefixHasBeenModified() {
474        return alwaysIncludePrefixHasBeenModified;
475    }
476    
477    public String getSuffix() {
478        return suffix;
479    }
480    
481    public void setSuffix(String suffix) {
482        boolean update = true;
483        
484        if(this.suffix != null) {
485            if(this.suffix.equals(suffix)) {
486                update = false;
487            }
488        } else if(suffix == null) {
489            update = false;
490        }
491        
492        if(update) {
493            this.suffix = suffix;
494            suffixHasBeenModified = true;
495            clearHashAndString();
496        }
497    }
498    
499    public boolean getSuffixHasBeenModified() {
500        return suffixHasBeenModified;
501    }
502    
503    public Boolean getAlwaysIncludeSuffix() {
504        return alwaysIncludeSuffix;
505    }
506    
507    public void setAlwaysIncludeSuffix(Boolean alwaysIncludeSuffix)
508            throws PersistenceNotNullException {
509        checkForNull(alwaysIncludeSuffix);
510        
511        boolean update = true;
512        
513        if(this.alwaysIncludeSuffix != null) {
514            if(this.alwaysIncludeSuffix.equals(alwaysIncludeSuffix)) {
515                update = false;
516            }
517        } else if(alwaysIncludeSuffix == null) {
518            update = false;
519        }
520        
521        if(update) {
522            this.alwaysIncludeSuffix = alwaysIncludeSuffix;
523            alwaysIncludeSuffixHasBeenModified = true;
524            clearHashAndString();
525        }
526    }
527    
528    public boolean getAlwaysIncludeSuffixHasBeenModified() {
529        return alwaysIncludeSuffixHasBeenModified;
530    }
531    
532    public Long getFromTime() {
533        return fromTime;
534    }
535    
536    public void setFromTime(Long fromTime)
537            throws PersistenceNotNullException {
538        checkForNull(fromTime);
539        
540        boolean update = true;
541        
542        if(this.fromTime != null) {
543            if(this.fromTime.equals(fromTime)) {
544                update = false;
545            }
546        } else if(fromTime == null) {
547            update = false;
548        }
549        
550        if(update) {
551            this.fromTime = fromTime;
552            fromTimeHasBeenModified = true;
553            clearHashAndString();
554        }
555    }
556    
557    public boolean getFromTimeHasBeenModified() {
558        return fromTimeHasBeenModified;
559    }
560    
561    public Long getThruTime() {
562        return thruTime;
563    }
564    
565    public void setThruTime(Long thruTime)
566            throws PersistenceNotNullException {
567        checkForNull(thruTime);
568        
569        boolean update = true;
570        
571        if(this.thruTime != null) {
572            if(this.thruTime.equals(thruTime)) {
573                update = false;
574            }
575        } else if(thruTime == null) {
576            update = false;
577        }
578        
579        if(update) {
580            this.thruTime = thruTime;
581            thruTimeHasBeenModified = true;
582            clearHashAndString();
583        }
584    }
585    
586    public boolean getThruTimeHasBeenModified() {
587        return thruTimeHasBeenModified;
588    }
589    
590}