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