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