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