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