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 * AssociateReferralDetailValue.java
021 */
022
023package com.echothree.model.data.associate.server.value;
024
025import com.echothree.model.data.associate.common.pk.AssociateReferralDetailPK;
026
027import com.echothree.model.data.associate.server.factory.AssociateReferralDetailFactory;
028
029import com.echothree.model.data.associate.common.pk.AssociateReferralPK;
030import com.echothree.model.data.associate.common.pk.AssociatePK;
031import com.echothree.model.data.associate.common.pk.AssociatePartyContactMechanismPK;
032import com.echothree.model.data.core.common.pk.EntityInstancePK;
033
034import com.echothree.util.common.exception.PersistenceCloneException;
035import com.echothree.util.common.exception.PersistenceNotNullException;
036
037import com.echothree.util.server.persistence.BaseValue;
038
039import java.io.Serializable;
040
041public class AssociateReferralDetailValue
042        extends BaseValue<AssociateReferralDetailPK>
043        implements Cloneable, Serializable {
044    
045    private AssociateReferralPK associateReferralPK;
046    private boolean associateReferralPKHasBeenModified = false;
047    private String associateReferralName;
048    private boolean associateReferralNameHasBeenModified = false;
049    private AssociatePK associatePK;
050    private boolean associatePKHasBeenModified = false;
051    private AssociatePartyContactMechanismPK associatePartyContactMechanismPK;
052    private boolean associatePartyContactMechanismPKHasBeenModified = false;
053    private EntityInstancePK targetEntityInstancePK;
054    private boolean targetEntityInstancePKHasBeenModified = false;
055    private Long associateReferralTime;
056    private boolean associateReferralTimeHasBeenModified = 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(AssociateReferralPK associateReferralPK, String associateReferralName, AssociatePK associatePK, AssociatePartyContactMechanismPK associatePartyContactMechanismPK, EntityInstancePK targetEntityInstancePK, Long associateReferralTime, Long fromTime, Long thruTime)
066            throws PersistenceNotNullException {
067        this.associateReferralPK = associateReferralPK;
068        checkForNull(associateReferralName);
069        this.associateReferralName = associateReferralName;
070        checkForNull(associatePK);
071        this.associatePK = associatePK;
072        this.associatePartyContactMechanismPK = associatePartyContactMechanismPK;
073        this.targetEntityInstancePK = targetEntityInstancePK;
074        checkForNull(associateReferralTime);
075        this.associateReferralTime = associateReferralTime;
076        checkForNull(fromTime);
077        this.fromTime = fromTime;
078        checkForNull(thruTime);
079        this.thruTime = thruTime;
080    }
081    
082    /** Creates a new instance of AssociateReferralDetailValue */
083    public AssociateReferralDetailValue(AssociateReferralDetailPK associateReferralDetailPK, AssociateReferralPK associateReferralPK, String associateReferralName, AssociatePK associatePK, AssociatePartyContactMechanismPK associatePartyContactMechanismPK, EntityInstancePK targetEntityInstancePK, Long associateReferralTime, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super(associateReferralDetailPK);
086        constructFields(associateReferralPK, associateReferralName, associatePK, associatePartyContactMechanismPK, targetEntityInstancePK, associateReferralTime, fromTime, thruTime);
087    }
088    
089    /** Creates a new instance of AssociateReferralDetailValue */
090    public AssociateReferralDetailValue(AssociateReferralPK associateReferralPK, String associateReferralName, AssociatePK associatePK, AssociatePartyContactMechanismPK associatePartyContactMechanismPK, EntityInstancePK targetEntityInstancePK, Long associateReferralTime, Long fromTime, Long thruTime)
091            throws PersistenceNotNullException {
092        super();
093        constructFields(associateReferralPK, associateReferralName, associatePK, associatePartyContactMechanismPK, targetEntityInstancePK, associateReferralTime, fromTime, thruTime);
094    }
095    
096   @Override
097   public AssociateReferralDetailFactory getBaseFactoryInstance() {
098        return AssociateReferralDetailFactory.getInstance();
099    }
100    
101    @Override
102    public AssociateReferralDetailValue clone() {
103        Object result;
104        
105        try {
106            result = super.clone();
107        } catch (CloneNotSupportedException cnse) {
108            // This shouldn't happen, fail when it does.
109            throw new PersistenceCloneException(cnse);
110        }
111        
112        return (AssociateReferralDetailValue)result;
113    }
114    
115   @Override
116    public AssociateReferralDetailPK getPrimaryKey() {
117        if(_primaryKey == null) {
118            _primaryKey = new AssociateReferralDetailPK(entityId);
119        }
120        
121        return _primaryKey;
122    }
123    
124    private void clearHashAndString() {
125        _hashCode = null;
126        _stringValue = null;
127    }
128    
129    @Override
130    public int hashCode() {
131        if(_hashCode == null) {
132            int hashCode = 17;
133            
134            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
135            
136            hashCode = 37 * hashCode + ((associateReferralPK != null) ? associateReferralPK.hashCode() : 0);
137            hashCode = 37 * hashCode + ((associateReferralName != null) ? associateReferralName.hashCode() : 0);
138            hashCode = 37 * hashCode + ((associatePK != null) ? associatePK.hashCode() : 0);
139            hashCode = 37 * hashCode + ((associatePartyContactMechanismPK != null) ? associatePartyContactMechanismPK.hashCode() : 0);
140            hashCode = 37 * hashCode + ((targetEntityInstancePK != null) ? targetEntityInstancePK.hashCode() : 0);
141            hashCode = 37 * hashCode + ((associateReferralTime != null) ? associateReferralTime.hashCode() : 0);
142            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
143            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
144            
145            _hashCode = hashCode;
146        }
147        
148        return _hashCode;
149    }
150    
151    @Override
152    public String toString() {
153        if(_stringValue == null) {
154            StringBuilder stringValue = new StringBuilder("{");
155            
156            stringValue.append("entityId=").append(getEntityId());
157            
158            stringValue.append(", associateReferralPK=").append(getAssociateReferralPK());
159            stringValue.append(", associateReferralName=").append(getAssociateReferralName());
160            stringValue.append(", associatePK=").append(getAssociatePK());
161            stringValue.append(", associatePartyContactMechanismPK=").append(getAssociatePartyContactMechanismPK());
162            stringValue.append(", targetEntityInstancePK=").append(getTargetEntityInstancePK());
163            stringValue.append(", associateReferralTime=").append(getAssociateReferralTime());
164            stringValue.append(", fromTime=").append(getFromTime());
165            stringValue.append(", thruTime=").append(getThruTime());
166            
167            stringValue.append('}');
168            
169            _stringValue = stringValue.toString();
170        }
171        return _stringValue;
172    }
173    
174    @Override
175    public boolean equals(Object other) {
176        if(this == other)
177            return true;
178        
179        if(!hasIdentity())
180            return false;
181        
182        if(other instanceof  AssociateReferralDetailValue) {
183            AssociateReferralDetailValue that = (AssociateReferralDetailValue)other;
184            
185            if(!that.hasIdentity())
186                return false;
187            
188            Long thisEntityId = getEntityId();
189            Long thatEntityId = that.getEntityId();
190            
191            boolean objectsEqual = thisEntityId.equals(thatEntityId);
192            if(objectsEqual)
193                objectsEqual = objectsEqual && isIdentical(that);
194            
195            return objectsEqual;
196        } else {
197            return false;
198        }
199    }
200    
201    public boolean isIdentical(Object other) {
202        if(other instanceof AssociateReferralDetailValue) {
203            AssociateReferralDetailValue that = (AssociateReferralDetailValue)other;
204            boolean objectsEqual = true;
205            
206            
207            if(objectsEqual) {
208                AssociateReferralPK thisAssociateReferralPK = getAssociateReferralPK();
209                AssociateReferralPK thatAssociateReferralPK = that.getAssociateReferralPK();
210                
211                if(thisAssociateReferralPK == null) {
212                    objectsEqual = objectsEqual && (thatAssociateReferralPK == null);
213                } else {
214                    objectsEqual = objectsEqual && thisAssociateReferralPK.equals(thatAssociateReferralPK);
215                }
216            }
217            
218            if(objectsEqual) {
219                String thisAssociateReferralName = getAssociateReferralName();
220                String thatAssociateReferralName = that.getAssociateReferralName();
221                
222                if(thisAssociateReferralName == null) {
223                    objectsEqual = objectsEqual && (thatAssociateReferralName == null);
224                } else {
225                    objectsEqual = objectsEqual && thisAssociateReferralName.equals(thatAssociateReferralName);
226                }
227            }
228            
229            if(objectsEqual) {
230                AssociatePK thisAssociatePK = getAssociatePK();
231                AssociatePK thatAssociatePK = that.getAssociatePK();
232                
233                if(thisAssociatePK == null) {
234                    objectsEqual = objectsEqual && (thatAssociatePK == null);
235                } else {
236                    objectsEqual = objectsEqual && thisAssociatePK.equals(thatAssociatePK);
237                }
238            }
239            
240            if(objectsEqual) {
241                AssociatePartyContactMechanismPK thisAssociatePartyContactMechanismPK = getAssociatePartyContactMechanismPK();
242                AssociatePartyContactMechanismPK thatAssociatePartyContactMechanismPK = that.getAssociatePartyContactMechanismPK();
243                
244                if(thisAssociatePartyContactMechanismPK == null) {
245                    objectsEqual = objectsEqual && (thatAssociatePartyContactMechanismPK == null);
246                } else {
247                    objectsEqual = objectsEqual && thisAssociatePartyContactMechanismPK.equals(thatAssociatePartyContactMechanismPK);
248                }
249            }
250            
251            if(objectsEqual) {
252                EntityInstancePK thisTargetEntityInstancePK = getTargetEntityInstancePK();
253                EntityInstancePK thatTargetEntityInstancePK = that.getTargetEntityInstancePK();
254                
255                if(thisTargetEntityInstancePK == null) {
256                    objectsEqual = objectsEqual && (thatTargetEntityInstancePK == null);
257                } else {
258                    objectsEqual = objectsEqual && thisTargetEntityInstancePK.equals(thatTargetEntityInstancePK);
259                }
260            }
261            
262            if(objectsEqual) {
263                Long thisAssociateReferralTime = getAssociateReferralTime();
264                Long thatAssociateReferralTime = that.getAssociateReferralTime();
265                
266                if(thisAssociateReferralTime == null) {
267                    objectsEqual = objectsEqual && (thatAssociateReferralTime == null);
268                } else {
269                    objectsEqual = objectsEqual && thisAssociateReferralTime.equals(thatAssociateReferralTime);
270                }
271            }
272            
273            if(objectsEqual) {
274                Long thisFromTime = getFromTime();
275                Long thatFromTime = that.getFromTime();
276                
277                if(thisFromTime == null) {
278                    objectsEqual = objectsEqual && (thatFromTime == null);
279                } else {
280                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
281                }
282            }
283            
284            if(objectsEqual) {
285                Long thisThruTime = getThruTime();
286                Long thatThruTime = that.getThruTime();
287                
288                if(thisThruTime == null) {
289                    objectsEqual = objectsEqual && (thatThruTime == null);
290                } else {
291                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
292                }
293            }
294            
295            return objectsEqual;
296        } else {
297            return false;
298        }
299    }
300    
301    @Override
302    public boolean hasBeenModified() {
303        return associateReferralPKHasBeenModified || associateReferralNameHasBeenModified || associatePKHasBeenModified || associatePartyContactMechanismPKHasBeenModified || targetEntityInstancePKHasBeenModified || associateReferralTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
304    }
305    
306    @Override
307    public void clearHasBeenModified() {
308        associateReferralPKHasBeenModified = false;
309        associateReferralNameHasBeenModified = false;
310        associatePKHasBeenModified = false;
311        associatePartyContactMechanismPKHasBeenModified = false;
312        targetEntityInstancePKHasBeenModified = false;
313        associateReferralTimeHasBeenModified = false;
314        fromTimeHasBeenModified = false;
315        thruTimeHasBeenModified = false;
316    }
317    
318    public AssociateReferralPK getAssociateReferralPK() {
319        return associateReferralPK;
320    }
321    
322    public void setAssociateReferralPK(AssociateReferralPK associateReferralPK) {
323        boolean update = true;
324        
325        if(this.associateReferralPK != null) {
326            if(this.associateReferralPK.equals(associateReferralPK)) {
327                update = false;
328            }
329        } else if(associateReferralPK == null) {
330            update = false;
331        }
332        
333        if(update) {
334            this.associateReferralPK = associateReferralPK;
335            associateReferralPKHasBeenModified = true;
336            clearHashAndString();
337        }
338    }
339    
340    public boolean getAssociateReferralPKHasBeenModified() {
341        return associateReferralPKHasBeenModified;
342    }
343    
344    public String getAssociateReferralName() {
345        return associateReferralName;
346    }
347    
348    public void setAssociateReferralName(String associateReferralName)
349            throws PersistenceNotNullException {
350        checkForNull(associateReferralName);
351        
352        boolean update = true;
353        
354        if(this.associateReferralName != null) {
355            if(this.associateReferralName.equals(associateReferralName)) {
356                update = false;
357            }
358        } else if(associateReferralName == null) {
359            update = false;
360        }
361        
362        if(update) {
363            this.associateReferralName = associateReferralName;
364            associateReferralNameHasBeenModified = true;
365            clearHashAndString();
366        }
367    }
368    
369    public boolean getAssociateReferralNameHasBeenModified() {
370        return associateReferralNameHasBeenModified;
371    }
372    
373    public AssociatePK getAssociatePK() {
374        return associatePK;
375    }
376    
377    public void setAssociatePK(AssociatePK associatePK)
378            throws PersistenceNotNullException {
379        checkForNull(associatePK);
380        
381        boolean update = true;
382        
383        if(this.associatePK != null) {
384            if(this.associatePK.equals(associatePK)) {
385                update = false;
386            }
387        } else if(associatePK == null) {
388            update = false;
389        }
390        
391        if(update) {
392            this.associatePK = associatePK;
393            associatePKHasBeenModified = true;
394            clearHashAndString();
395        }
396    }
397    
398    public boolean getAssociatePKHasBeenModified() {
399        return associatePKHasBeenModified;
400    }
401    
402    public AssociatePartyContactMechanismPK getAssociatePartyContactMechanismPK() {
403        return associatePartyContactMechanismPK;
404    }
405    
406    public void setAssociatePartyContactMechanismPK(AssociatePartyContactMechanismPK associatePartyContactMechanismPK) {
407        boolean update = true;
408        
409        if(this.associatePartyContactMechanismPK != null) {
410            if(this.associatePartyContactMechanismPK.equals(associatePartyContactMechanismPK)) {
411                update = false;
412            }
413        } else if(associatePartyContactMechanismPK == null) {
414            update = false;
415        }
416        
417        if(update) {
418            this.associatePartyContactMechanismPK = associatePartyContactMechanismPK;
419            associatePartyContactMechanismPKHasBeenModified = true;
420            clearHashAndString();
421        }
422    }
423    
424    public boolean getAssociatePartyContactMechanismPKHasBeenModified() {
425        return associatePartyContactMechanismPKHasBeenModified;
426    }
427    
428    public EntityInstancePK getTargetEntityInstancePK() {
429        return targetEntityInstancePK;
430    }
431    
432    public void setTargetEntityInstancePK(EntityInstancePK targetEntityInstancePK) {
433        boolean update = true;
434        
435        if(this.targetEntityInstancePK != null) {
436            if(this.targetEntityInstancePK.equals(targetEntityInstancePK)) {
437                update = false;
438            }
439        } else if(targetEntityInstancePK == null) {
440            update = false;
441        }
442        
443        if(update) {
444            this.targetEntityInstancePK = targetEntityInstancePK;
445            targetEntityInstancePKHasBeenModified = true;
446            clearHashAndString();
447        }
448    }
449    
450    public boolean getTargetEntityInstancePKHasBeenModified() {
451        return targetEntityInstancePKHasBeenModified;
452    }
453    
454    public Long getAssociateReferralTime() {
455        return associateReferralTime;
456    }
457    
458    public void setAssociateReferralTime(Long associateReferralTime)
459            throws PersistenceNotNullException {
460        checkForNull(associateReferralTime);
461        
462        boolean update = true;
463        
464        if(this.associateReferralTime != null) {
465            if(this.associateReferralTime.equals(associateReferralTime)) {
466                update = false;
467            }
468        } else if(associateReferralTime == null) {
469            update = false;
470        }
471        
472        if(update) {
473            this.associateReferralTime = associateReferralTime;
474            associateReferralTimeHasBeenModified = true;
475            clearHashAndString();
476        }
477    }
478    
479    public boolean getAssociateReferralTimeHasBeenModified() {
480        return associateReferralTimeHasBeenModified;
481    }
482    
483    public Long getFromTime() {
484        return fromTime;
485    }
486    
487    public void setFromTime(Long fromTime)
488            throws PersistenceNotNullException {
489        checkForNull(fromTime);
490        
491        boolean update = true;
492        
493        if(this.fromTime != null) {
494            if(this.fromTime.equals(fromTime)) {
495                update = false;
496            }
497        } else if(fromTime == null) {
498            update = false;
499        }
500        
501        if(update) {
502            this.fromTime = fromTime;
503            fromTimeHasBeenModified = true;
504            clearHashAndString();
505        }
506    }
507    
508    public boolean getFromTimeHasBeenModified() {
509        return fromTimeHasBeenModified;
510    }
511    
512    public Long getThruTime() {
513        return thruTime;
514    }
515    
516    public void setThruTime(Long thruTime)
517            throws PersistenceNotNullException {
518        checkForNull(thruTime);
519        
520        boolean update = true;
521        
522        if(this.thruTime != null) {
523            if(this.thruTime.equals(thruTime)) {
524                update = false;
525            }
526        } else if(thruTime == null) {
527            update = false;
528        }
529        
530        if(update) {
531            this.thruTime = thruTime;
532            thruTimeHasBeenModified = true;
533            clearHashAndString();
534        }
535    }
536    
537    public boolean getThruTimeHasBeenModified() {
538        return thruTimeHasBeenModified;
539    }
540    
541}