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