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 * InvoiceDetailValue.java
021 */
022
023package com.echothree.model.data.invoice.server.value;
024
025import com.echothree.model.data.invoice.common.pk.InvoiceDetailPK;
026
027import com.echothree.model.data.invoice.server.factory.InvoiceDetailFactory;
028
029import com.echothree.model.data.invoice.common.pk.InvoicePK;
030import com.echothree.model.data.invoice.common.pk.InvoiceTypePK;
031import com.echothree.model.data.payment.common.pk.BillingAccountPK;
032import com.echothree.model.data.accounting.common.pk.GlAccountPK;
033import com.echothree.model.data.term.common.pk.TermPK;
034import com.echothree.model.data.shipment.common.pk.FreeOnBoardPK;
035
036import com.echothree.util.common.exception.PersistenceCloneException;
037import com.echothree.util.common.exception.PersistenceNotNullException;
038
039import com.echothree.util.server.persistence.BaseValue;
040
041import java.io.Serializable;
042
043public class InvoiceDetailValue
044        extends BaseValue<InvoiceDetailPK>
045        implements Cloneable, Serializable {
046    
047    private InvoicePK invoicePK;
048    private boolean invoicePKHasBeenModified = false;
049    private InvoiceTypePK invoiceTypePK;
050    private boolean invoiceTypePKHasBeenModified = false;
051    private String invoiceName;
052    private boolean invoiceNameHasBeenModified = false;
053    private BillingAccountPK billingAccountPK;
054    private boolean billingAccountPKHasBeenModified = false;
055    private GlAccountPK glAccountPK;
056    private boolean glAccountPKHasBeenModified = false;
057    private TermPK termPK;
058    private boolean termPKHasBeenModified = false;
059    private FreeOnBoardPK freeOnBoardPK;
060    private boolean freeOnBoardPKHasBeenModified = false;
061    private String reference;
062    private boolean referenceHasBeenModified = false;
063    private String description;
064    private boolean descriptionHasBeenModified = false;
065    private Long fromTime;
066    private boolean fromTimeHasBeenModified = false;
067    private Long thruTime;
068    private boolean thruTimeHasBeenModified = false;
069    
070    private transient Integer _hashCode = null;
071    private transient String _stringValue = null;
072    
073    private void constructFields(InvoicePK invoicePK, InvoiceTypePK invoiceTypePK, String invoiceName, BillingAccountPK billingAccountPK, GlAccountPK glAccountPK, TermPK termPK, FreeOnBoardPK freeOnBoardPK, String reference, String description, Long fromTime, Long thruTime)
074            throws PersistenceNotNullException {
075        checkForNull(invoicePK);
076        this.invoicePK = invoicePK;
077        checkForNull(invoiceTypePK);
078        this.invoiceTypePK = invoiceTypePK;
079        checkForNull(invoiceName);
080        this.invoiceName = invoiceName;
081        checkForNull(billingAccountPK);
082        this.billingAccountPK = billingAccountPK;
083        checkForNull(glAccountPK);
084        this.glAccountPK = glAccountPK;
085        checkForNull(termPK);
086        this.termPK = termPK;
087        this.freeOnBoardPK = freeOnBoardPK;
088        this.reference = reference;
089        this.description = description;
090        checkForNull(fromTime);
091        this.fromTime = fromTime;
092        checkForNull(thruTime);
093        this.thruTime = thruTime;
094    }
095    
096    /** Creates a new instance of InvoiceDetailValue */
097    public InvoiceDetailValue(InvoiceDetailPK invoiceDetailPK, InvoicePK invoicePK, InvoiceTypePK invoiceTypePK, String invoiceName, BillingAccountPK billingAccountPK, GlAccountPK glAccountPK, TermPK termPK, FreeOnBoardPK freeOnBoardPK, String reference, String description, Long fromTime, Long thruTime)
098            throws PersistenceNotNullException {
099        super(invoiceDetailPK);
100        constructFields(invoicePK, invoiceTypePK, invoiceName, billingAccountPK, glAccountPK, termPK, freeOnBoardPK, reference, description, fromTime, thruTime);
101    }
102    
103    /** Creates a new instance of InvoiceDetailValue */
104    public InvoiceDetailValue(InvoicePK invoicePK, InvoiceTypePK invoiceTypePK, String invoiceName, BillingAccountPK billingAccountPK, GlAccountPK glAccountPK, TermPK termPK, FreeOnBoardPK freeOnBoardPK, String reference, String description, Long fromTime, Long thruTime)
105            throws PersistenceNotNullException {
106        super();
107        constructFields(invoicePK, invoiceTypePK, invoiceName, billingAccountPK, glAccountPK, termPK, freeOnBoardPK, reference, description, fromTime, thruTime);
108    }
109    
110   @Override
111   public InvoiceDetailFactory getBaseFactoryInstance() {
112        return InvoiceDetailFactory.getInstance();
113    }
114    
115    @Override
116    public InvoiceDetailValue clone() {
117        Object result;
118        
119        try {
120            result = super.clone();
121        } catch (CloneNotSupportedException cnse) {
122            // This shouldn't happen, fail when it does.
123            throw new PersistenceCloneException(cnse);
124        }
125        
126        return (InvoiceDetailValue)result;
127    }
128    
129   @Override
130    public InvoiceDetailPK getPrimaryKey() {
131        if(_primaryKey == null) {
132            _primaryKey = new InvoiceDetailPK(entityId);
133        }
134        
135        return _primaryKey;
136    }
137    
138    private void clearHashAndString() {
139        _hashCode = null;
140        _stringValue = null;
141    }
142    
143    @Override
144    public int hashCode() {
145        if(_hashCode == null) {
146            int hashCode = 17;
147            
148            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
149            
150            hashCode = 37 * hashCode + ((invoicePK != null) ? invoicePK.hashCode() : 0);
151            hashCode = 37 * hashCode + ((invoiceTypePK != null) ? invoiceTypePK.hashCode() : 0);
152            hashCode = 37 * hashCode + ((invoiceName != null) ? invoiceName.hashCode() : 0);
153            hashCode = 37 * hashCode + ((billingAccountPK != null) ? billingAccountPK.hashCode() : 0);
154            hashCode = 37 * hashCode + ((glAccountPK != null) ? glAccountPK.hashCode() : 0);
155            hashCode = 37 * hashCode + ((termPK != null) ? termPK.hashCode() : 0);
156            hashCode = 37 * hashCode + ((freeOnBoardPK != null) ? freeOnBoardPK.hashCode() : 0);
157            hashCode = 37 * hashCode + ((reference != null) ? reference.hashCode() : 0);
158            hashCode = 37 * hashCode + ((description != null) ? description.hashCode() : 0);
159            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
160            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
161            
162            _hashCode = hashCode;
163        }
164        
165        return _hashCode;
166    }
167    
168    @Override
169    public String toString() {
170        if(_stringValue == null) {
171            _stringValue = "{" + 
172                    "entityId=" + getEntityId() +
173                    ", invoicePK=" + getInvoicePK() +
174                    ", invoiceTypePK=" + getInvoiceTypePK() +
175                    ", invoiceName=" + getInvoiceName() +
176                    ", billingAccountPK=" + getBillingAccountPK() +
177                    ", glAccountPK=" + getGlAccountPK() +
178                    ", termPK=" + getTermPK() +
179                    ", freeOnBoardPK=" + getFreeOnBoardPK() +
180                    ", reference=" + getReference() +
181                    ", description=" + getDescription() +
182                    ", fromTime=" + getFromTime() +
183                    ", thruTime=" + getThruTime() +
184                    "}";
185        }
186        return _stringValue;
187    }
188    
189    @Override
190    public boolean equals(Object other) {
191        if(this == other)
192            return true;
193        
194        if(!hasIdentity())
195            return false;
196        
197        if(other instanceof  InvoiceDetailValue that) {
198            if(!that.hasIdentity())
199                return false;
200            
201            Long thisEntityId = getEntityId();
202            Long thatEntityId = that.getEntityId();
203            
204            boolean objectsEqual = thisEntityId.equals(thatEntityId);
205            if(objectsEqual)
206                objectsEqual = isIdentical(that);
207            
208            return objectsEqual;
209        } else {
210            return false;
211        }
212    }
213    
214    public boolean isIdentical(Object other) {
215        if(other instanceof InvoiceDetailValue that) {
216            boolean objectsEqual = true;
217            
218            
219            if(objectsEqual) {
220                InvoicePK thisInvoicePK = getInvoicePK();
221                InvoicePK thatInvoicePK = that.getInvoicePK();
222                
223                if(thisInvoicePK == null) {
224                    objectsEqual = objectsEqual && (thatInvoicePK == null);
225                } else {
226                    objectsEqual = objectsEqual && thisInvoicePK.equals(thatInvoicePK);
227                }
228            }
229            
230            if(objectsEqual) {
231                InvoiceTypePK thisInvoiceTypePK = getInvoiceTypePK();
232                InvoiceTypePK thatInvoiceTypePK = that.getInvoiceTypePK();
233                
234                if(thisInvoiceTypePK == null) {
235                    objectsEqual = objectsEqual && (thatInvoiceTypePK == null);
236                } else {
237                    objectsEqual = objectsEqual && thisInvoiceTypePK.equals(thatInvoiceTypePK);
238                }
239            }
240            
241            if(objectsEqual) {
242                String thisInvoiceName = getInvoiceName();
243                String thatInvoiceName = that.getInvoiceName();
244                
245                if(thisInvoiceName == null) {
246                    objectsEqual = objectsEqual && (thatInvoiceName == null);
247                } else {
248                    objectsEqual = objectsEqual && thisInvoiceName.equals(thatInvoiceName);
249                }
250            }
251            
252            if(objectsEqual) {
253                BillingAccountPK thisBillingAccountPK = getBillingAccountPK();
254                BillingAccountPK thatBillingAccountPK = that.getBillingAccountPK();
255                
256                if(thisBillingAccountPK == null) {
257                    objectsEqual = objectsEqual && (thatBillingAccountPK == null);
258                } else {
259                    objectsEqual = objectsEqual && thisBillingAccountPK.equals(thatBillingAccountPK);
260                }
261            }
262            
263            if(objectsEqual) {
264                GlAccountPK thisGlAccountPK = getGlAccountPK();
265                GlAccountPK thatGlAccountPK = that.getGlAccountPK();
266                
267                if(thisGlAccountPK == null) {
268                    objectsEqual = objectsEqual && (thatGlAccountPK == null);
269                } else {
270                    objectsEqual = objectsEqual && thisGlAccountPK.equals(thatGlAccountPK);
271                }
272            }
273            
274            if(objectsEqual) {
275                TermPK thisTermPK = getTermPK();
276                TermPK thatTermPK = that.getTermPK();
277                
278                if(thisTermPK == null) {
279                    objectsEqual = objectsEqual && (thatTermPK == null);
280                } else {
281                    objectsEqual = objectsEqual && thisTermPK.equals(thatTermPK);
282                }
283            }
284            
285            if(objectsEqual) {
286                FreeOnBoardPK thisFreeOnBoardPK = getFreeOnBoardPK();
287                FreeOnBoardPK thatFreeOnBoardPK = that.getFreeOnBoardPK();
288                
289                if(thisFreeOnBoardPK == null) {
290                    objectsEqual = objectsEqual && (thatFreeOnBoardPK == null);
291                } else {
292                    objectsEqual = objectsEqual && thisFreeOnBoardPK.equals(thatFreeOnBoardPK);
293                }
294            }
295            
296            if(objectsEqual) {
297                String thisReference = getReference();
298                String thatReference = that.getReference();
299                
300                if(thisReference == null) {
301                    objectsEqual = objectsEqual && (thatReference == null);
302                } else {
303                    objectsEqual = objectsEqual && thisReference.equals(thatReference);
304                }
305            }
306            
307            if(objectsEqual) {
308                String thisDescription = getDescription();
309                String thatDescription = that.getDescription();
310                
311                if(thisDescription == null) {
312                    objectsEqual = objectsEqual && (thatDescription == null);
313                } else {
314                    objectsEqual = objectsEqual && thisDescription.equals(thatDescription);
315                }
316            }
317            
318            if(objectsEqual) {
319                Long thisFromTime = getFromTime();
320                Long thatFromTime = that.getFromTime();
321                
322                if(thisFromTime == null) {
323                    objectsEqual = objectsEqual && (thatFromTime == null);
324                } else {
325                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
326                }
327            }
328            
329            if(objectsEqual) {
330                Long thisThruTime = getThruTime();
331                Long thatThruTime = that.getThruTime();
332                
333                if(thisThruTime == null) {
334                    objectsEqual = objectsEqual && (thatThruTime == null);
335                } else {
336                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
337                }
338            }
339            
340            return objectsEqual;
341        } else {
342            return false;
343        }
344    }
345    
346    @Override
347    public boolean hasBeenModified() {
348        return invoicePKHasBeenModified || invoiceTypePKHasBeenModified || invoiceNameHasBeenModified || billingAccountPKHasBeenModified || glAccountPKHasBeenModified || termPKHasBeenModified || freeOnBoardPKHasBeenModified || referenceHasBeenModified || descriptionHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
349    }
350    
351    @Override
352    public void clearHasBeenModified() {
353        invoicePKHasBeenModified = false;
354        invoiceTypePKHasBeenModified = false;
355        invoiceNameHasBeenModified = false;
356        billingAccountPKHasBeenModified = false;
357        glAccountPKHasBeenModified = false;
358        termPKHasBeenModified = false;
359        freeOnBoardPKHasBeenModified = false;
360        referenceHasBeenModified = false;
361        descriptionHasBeenModified = false;
362        fromTimeHasBeenModified = false;
363        thruTimeHasBeenModified = false;
364    }
365    
366    public InvoicePK getInvoicePK() {
367        return invoicePK;
368    }
369    
370    public void setInvoicePK(InvoicePK invoicePK)
371            throws PersistenceNotNullException {
372        checkForNull(invoicePK);
373        
374        boolean update = true;
375        
376        if(this.invoicePK != null) {
377            if(this.invoicePK.equals(invoicePK)) {
378                update = false;
379            }
380        } else if(invoicePK == null) {
381            update = false;
382        }
383        
384        if(update) {
385            this.invoicePK = invoicePK;
386            invoicePKHasBeenModified = true;
387            clearHashAndString();
388        }
389    }
390    
391    public boolean getInvoicePKHasBeenModified() {
392        return invoicePKHasBeenModified;
393    }
394    
395    public InvoiceTypePK getInvoiceTypePK() {
396        return invoiceTypePK;
397    }
398    
399    public void setInvoiceTypePK(InvoiceTypePK invoiceTypePK)
400            throws PersistenceNotNullException {
401        checkForNull(invoiceTypePK);
402        
403        boolean update = true;
404        
405        if(this.invoiceTypePK != null) {
406            if(this.invoiceTypePK.equals(invoiceTypePK)) {
407                update = false;
408            }
409        } else if(invoiceTypePK == null) {
410            update = false;
411        }
412        
413        if(update) {
414            this.invoiceTypePK = invoiceTypePK;
415            invoiceTypePKHasBeenModified = true;
416            clearHashAndString();
417        }
418    }
419    
420    public boolean getInvoiceTypePKHasBeenModified() {
421        return invoiceTypePKHasBeenModified;
422    }
423    
424    public String getInvoiceName() {
425        return invoiceName;
426    }
427    
428    public void setInvoiceName(String invoiceName)
429            throws PersistenceNotNullException {
430        checkForNull(invoiceName);
431        
432        boolean update = true;
433        
434        if(this.invoiceName != null) {
435            if(this.invoiceName.equals(invoiceName)) {
436                update = false;
437            }
438        } else if(invoiceName == null) {
439            update = false;
440        }
441        
442        if(update) {
443            this.invoiceName = invoiceName;
444            invoiceNameHasBeenModified = true;
445            clearHashAndString();
446        }
447    }
448    
449    public boolean getInvoiceNameHasBeenModified() {
450        return invoiceNameHasBeenModified;
451    }
452    
453    public BillingAccountPK getBillingAccountPK() {
454        return billingAccountPK;
455    }
456    
457    public void setBillingAccountPK(BillingAccountPK billingAccountPK)
458            throws PersistenceNotNullException {
459        checkForNull(billingAccountPK);
460        
461        boolean update = true;
462        
463        if(this.billingAccountPK != null) {
464            if(this.billingAccountPK.equals(billingAccountPK)) {
465                update = false;
466            }
467        } else if(billingAccountPK == null) {
468            update = false;
469        }
470        
471        if(update) {
472            this.billingAccountPK = billingAccountPK;
473            billingAccountPKHasBeenModified = true;
474            clearHashAndString();
475        }
476    }
477    
478    public boolean getBillingAccountPKHasBeenModified() {
479        return billingAccountPKHasBeenModified;
480    }
481    
482    public GlAccountPK getGlAccountPK() {
483        return glAccountPK;
484    }
485    
486    public void setGlAccountPK(GlAccountPK glAccountPK)
487            throws PersistenceNotNullException {
488        checkForNull(glAccountPK);
489        
490        boolean update = true;
491        
492        if(this.glAccountPK != null) {
493            if(this.glAccountPK.equals(glAccountPK)) {
494                update = false;
495            }
496        } else if(glAccountPK == null) {
497            update = false;
498        }
499        
500        if(update) {
501            this.glAccountPK = glAccountPK;
502            glAccountPKHasBeenModified = true;
503            clearHashAndString();
504        }
505    }
506    
507    public boolean getGlAccountPKHasBeenModified() {
508        return glAccountPKHasBeenModified;
509    }
510    
511    public TermPK getTermPK() {
512        return termPK;
513    }
514    
515    public void setTermPK(TermPK termPK)
516            throws PersistenceNotNullException {
517        checkForNull(termPK);
518        
519        boolean update = true;
520        
521        if(this.termPK != null) {
522            if(this.termPK.equals(termPK)) {
523                update = false;
524            }
525        } else if(termPK == null) {
526            update = false;
527        }
528        
529        if(update) {
530            this.termPK = termPK;
531            termPKHasBeenModified = true;
532            clearHashAndString();
533        }
534    }
535    
536    public boolean getTermPKHasBeenModified() {
537        return termPKHasBeenModified;
538    }
539    
540    public FreeOnBoardPK getFreeOnBoardPK() {
541        return freeOnBoardPK;
542    }
543    
544    public void setFreeOnBoardPK(FreeOnBoardPK freeOnBoardPK) {
545        boolean update = true;
546        
547        if(this.freeOnBoardPK != null) {
548            if(this.freeOnBoardPK.equals(freeOnBoardPK)) {
549                update = false;
550            }
551        } else if(freeOnBoardPK == null) {
552            update = false;
553        }
554        
555        if(update) {
556            this.freeOnBoardPK = freeOnBoardPK;
557            freeOnBoardPKHasBeenModified = true;
558            clearHashAndString();
559        }
560    }
561    
562    public boolean getFreeOnBoardPKHasBeenModified() {
563        return freeOnBoardPKHasBeenModified;
564    }
565    
566    public String getReference() {
567        return reference;
568    }
569    
570    public void setReference(String reference) {
571        boolean update = true;
572        
573        if(this.reference != null) {
574            if(this.reference.equals(reference)) {
575                update = false;
576            }
577        } else if(reference == null) {
578            update = false;
579        }
580        
581        if(update) {
582            this.reference = reference;
583            referenceHasBeenModified = true;
584            clearHashAndString();
585        }
586    }
587    
588    public boolean getReferenceHasBeenModified() {
589        return referenceHasBeenModified;
590    }
591    
592    public String getDescription() {
593        return description;
594    }
595    
596    public void setDescription(String description) {
597        boolean update = true;
598        
599        if(this.description != null) {
600            if(this.description.equals(description)) {
601                update = false;
602            }
603        } else if(description == null) {
604            update = false;
605        }
606        
607        if(update) {
608            this.description = description;
609            descriptionHasBeenModified = true;
610            clearHashAndString();
611        }
612    }
613    
614    public boolean getDescriptionHasBeenModified() {
615        return descriptionHasBeenModified;
616    }
617    
618    public Long getFromTime() {
619        return fromTime;
620    }
621    
622    public void setFromTime(Long fromTime)
623            throws PersistenceNotNullException {
624        checkForNull(fromTime);
625        
626        boolean update = true;
627        
628        if(this.fromTime != null) {
629            if(this.fromTime.equals(fromTime)) {
630                update = false;
631            }
632        } else if(fromTime == null) {
633            update = false;
634        }
635        
636        if(update) {
637            this.fromTime = fromTime;
638            fromTimeHasBeenModified = true;
639            clearHashAndString();
640        }
641    }
642    
643    public boolean getFromTimeHasBeenModified() {
644        return fromTimeHasBeenModified;
645    }
646    
647    public Long getThruTime() {
648        return thruTime;
649    }
650    
651    public void setThruTime(Long thruTime)
652            throws PersistenceNotNullException {
653        checkForNull(thruTime);
654        
655        boolean update = true;
656        
657        if(this.thruTime != null) {
658            if(this.thruTime.equals(thruTime)) {
659                update = false;
660            }
661        } else if(thruTime == null) {
662            update = false;
663        }
664        
665        if(update) {
666            this.thruTime = thruTime;
667            thruTimeHasBeenModified = true;
668            clearHashAndString();
669        }
670    }
671    
672    public boolean getThruTimeHasBeenModified() {
673        return thruTimeHasBeenModified;
674    }
675    
676}