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