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 * BillingAccountStatusValue.java
021 */
022
023package com.echothree.model.data.payment.server.value;
024
025import com.echothree.model.data.payment.common.pk.BillingAccountStatusPK;
026
027import com.echothree.model.data.payment.server.factory.BillingAccountStatusFactory;
028
029import com.echothree.model.data.payment.common.pk.BillingAccountPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038public class BillingAccountStatusValue
039        extends BaseValue<BillingAccountStatusPK>
040        implements Cloneable, Serializable {
041    
042    private BillingAccountPK billingAccountPK;
043    private boolean billingAccountPKHasBeenModified = false;
044    private Long creditLimit;
045    private boolean creditLimitHasBeenModified = false;
046    private Long potentialCreditLimit;
047    private boolean potentialCreditLimitHasBeenModified = false;
048    
049    private transient Integer _hashCode = null;
050    private transient String _stringValue = null;
051    
052    private void constructFields(BillingAccountPK billingAccountPK, Long creditLimit, Long potentialCreditLimit)
053            throws PersistenceNotNullException {
054        checkForNull(billingAccountPK);
055        this.billingAccountPK = billingAccountPK;
056        this.creditLimit = creditLimit;
057        this.potentialCreditLimit = potentialCreditLimit;
058    }
059    
060    /** Creates a new instance of BillingAccountStatusValue */
061    public BillingAccountStatusValue(BillingAccountStatusPK billingAccountStatusPK, BillingAccountPK billingAccountPK, Long creditLimit, Long potentialCreditLimit)
062            throws PersistenceNotNullException {
063        super(billingAccountStatusPK);
064        constructFields(billingAccountPK, creditLimit, potentialCreditLimit);
065    }
066    
067    /** Creates a new instance of BillingAccountStatusValue */
068    public BillingAccountStatusValue(BillingAccountPK billingAccountPK, Long creditLimit, Long potentialCreditLimit)
069            throws PersistenceNotNullException {
070        super();
071        constructFields(billingAccountPK, creditLimit, potentialCreditLimit);
072    }
073    
074   @Override
075   public BillingAccountStatusFactory getBaseFactoryInstance() {
076        return BillingAccountStatusFactory.getInstance();
077    }
078    
079    @Override
080    public BillingAccountStatusValue clone() {
081        Object result;
082        
083        try {
084            result = super.clone();
085        } catch (CloneNotSupportedException cnse) {
086            // This shouldn't happen, fail when it does.
087            throw new PersistenceCloneException(cnse);
088        }
089        
090        return (BillingAccountStatusValue)result;
091    }
092    
093   @Override
094    public BillingAccountStatusPK getPrimaryKey() {
095        if(_primaryKey == null) {
096            _primaryKey = new BillingAccountStatusPK(entityId);
097        }
098        
099        return _primaryKey;
100    }
101    
102    private void clearHashAndString() {
103        _hashCode = null;
104        _stringValue = null;
105    }
106    
107    @Override
108    public int hashCode() {
109        if(_hashCode == null) {
110            int hashCode = 17;
111            
112            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
113            
114            hashCode = 37 * hashCode + ((billingAccountPK != null) ? billingAccountPK.hashCode() : 0);
115            hashCode = 37 * hashCode + ((creditLimit != null) ? creditLimit.hashCode() : 0);
116            hashCode = 37 * hashCode + ((potentialCreditLimit != null) ? potentialCreditLimit.hashCode() : 0);
117            
118            _hashCode = hashCode;
119        }
120        
121        return _hashCode;
122    }
123    
124    @Override
125    public String toString() {
126        if(_stringValue == null) {
127            StringBuilder stringValue = new StringBuilder("{");
128            
129            stringValue.append("entityId=").append(getEntityId());
130            
131            stringValue.append(", billingAccountPK=").append(getBillingAccountPK());
132            stringValue.append(", creditLimit=").append(getCreditLimit());
133            stringValue.append(", potentialCreditLimit=").append(getPotentialCreditLimit());
134            
135            stringValue.append('}');
136            
137            _stringValue = stringValue.toString();
138        }
139        return _stringValue;
140    }
141    
142    @Override
143    public boolean equals(Object other) {
144        if(this == other)
145            return true;
146        
147        if(!hasIdentity())
148            return false;
149        
150        if(other instanceof  BillingAccountStatusValue) {
151            BillingAccountStatusValue that = (BillingAccountStatusValue)other;
152            
153            if(!that.hasIdentity())
154                return false;
155            
156            Long thisEntityId = getEntityId();
157            Long thatEntityId = that.getEntityId();
158            
159            boolean objectsEqual = thisEntityId.equals(thatEntityId);
160            if(objectsEqual)
161                objectsEqual = objectsEqual && isIdentical(that);
162            
163            return objectsEqual;
164        } else {
165            return false;
166        }
167    }
168    
169    public boolean isIdentical(Object other) {
170        if(other instanceof BillingAccountStatusValue) {
171            BillingAccountStatusValue that = (BillingAccountStatusValue)other;
172            boolean objectsEqual = true;
173            
174            
175            if(objectsEqual) {
176                BillingAccountPK thisBillingAccountPK = getBillingAccountPK();
177                BillingAccountPK thatBillingAccountPK = that.getBillingAccountPK();
178                
179                if(thisBillingAccountPK == null) {
180                    objectsEqual = objectsEqual && (thatBillingAccountPK == null);
181                } else {
182                    objectsEqual = objectsEqual && thisBillingAccountPK.equals(thatBillingAccountPK);
183                }
184            }
185            
186            if(objectsEqual) {
187                Long thisCreditLimit = getCreditLimit();
188                Long thatCreditLimit = that.getCreditLimit();
189                
190                if(thisCreditLimit == null) {
191                    objectsEqual = objectsEqual && (thatCreditLimit == null);
192                } else {
193                    objectsEqual = objectsEqual && thisCreditLimit.equals(thatCreditLimit);
194                }
195            }
196            
197            if(objectsEqual) {
198                Long thisPotentialCreditLimit = getPotentialCreditLimit();
199                Long thatPotentialCreditLimit = that.getPotentialCreditLimit();
200                
201                if(thisPotentialCreditLimit == null) {
202                    objectsEqual = objectsEqual && (thatPotentialCreditLimit == null);
203                } else {
204                    objectsEqual = objectsEqual && thisPotentialCreditLimit.equals(thatPotentialCreditLimit);
205                }
206            }
207            
208            return objectsEqual;
209        } else {
210            return false;
211        }
212    }
213    
214    @Override
215    public boolean hasBeenModified() {
216        return billingAccountPKHasBeenModified || creditLimitHasBeenModified || potentialCreditLimitHasBeenModified;
217    }
218    
219    @Override
220    public void clearHasBeenModified() {
221        billingAccountPKHasBeenModified = false;
222        creditLimitHasBeenModified = false;
223        potentialCreditLimitHasBeenModified = false;
224    }
225    
226    public BillingAccountPK getBillingAccountPK() {
227        return billingAccountPK;
228    }
229    
230    public void setBillingAccountPK(BillingAccountPK billingAccountPK)
231            throws PersistenceNotNullException {
232        checkForNull(billingAccountPK);
233        
234        boolean update = true;
235        
236        if(this.billingAccountPK != null) {
237            if(this.billingAccountPK.equals(billingAccountPK)) {
238                update = false;
239            }
240        } else if(billingAccountPK == null) {
241            update = false;
242        }
243        
244        if(update) {
245            this.billingAccountPK = billingAccountPK;
246            billingAccountPKHasBeenModified = true;
247            clearHashAndString();
248        }
249    }
250    
251    public boolean getBillingAccountPKHasBeenModified() {
252        return billingAccountPKHasBeenModified;
253    }
254    
255    public Long getCreditLimit() {
256        return creditLimit;
257    }
258    
259    public void setCreditLimit(Long creditLimit) {
260        boolean update = true;
261        
262        if(this.creditLimit != null) {
263            if(this.creditLimit.equals(creditLimit)) {
264                update = false;
265            }
266        } else if(creditLimit == null) {
267            update = false;
268        }
269        
270        if(update) {
271            this.creditLimit = creditLimit;
272            creditLimitHasBeenModified = true;
273            clearHashAndString();
274        }
275    }
276    
277    public boolean getCreditLimitHasBeenModified() {
278        return creditLimitHasBeenModified;
279    }
280    
281    public Long getPotentialCreditLimit() {
282        return potentialCreditLimit;
283    }
284    
285    public void setPotentialCreditLimit(Long potentialCreditLimit) {
286        boolean update = true;
287        
288        if(this.potentialCreditLimit != null) {
289            if(this.potentialCreditLimit.equals(potentialCreditLimit)) {
290                update = false;
291            }
292        } else if(potentialCreditLimit == null) {
293            update = false;
294        }
295        
296        if(update) {
297            this.potentialCreditLimit = potentialCreditLimit;
298            potentialCreditLimitHasBeenModified = true;
299            clearHashAndString();
300        }
301    }
302    
303    public boolean getPotentialCreditLimitHasBeenModified() {
304        return potentialCreditLimitHasBeenModified;
305    }
306    
307}