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