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