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 * 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 balance;
051    private boolean balanceHasBeenModified = false;
052    
053    private transient Integer _hashCode = null;
054    private transient String _stringValue = null;
055    
056    private void constructFields(GlAccountPK glAccountPK, PartyPK groupPartyPK, PeriodPK periodPK, Long balance)
057            throws PersistenceNotNullException {
058        checkForNull(glAccountPK);
059        this.glAccountPK = glAccountPK;
060        checkForNull(groupPartyPK);
061        this.groupPartyPK = groupPartyPK;
062        checkForNull(periodPK);
063        this.periodPK = periodPK;
064        checkForNull(balance);
065        this.balance = balance;
066    }
067    
068    /** Creates a new instance of GlAccountSummaryValue */
069    public GlAccountSummaryValue(GlAccountSummaryPK glAccountSummaryPK, GlAccountPK glAccountPK, PartyPK groupPartyPK, PeriodPK periodPK, Long balance)
070            throws PersistenceNotNullException {
071        super(glAccountSummaryPK);
072        constructFields(glAccountPK, groupPartyPK, periodPK, balance);
073    }
074    
075    /** Creates a new instance of GlAccountSummaryValue */
076    public GlAccountSummaryValue(GlAccountPK glAccountPK, PartyPK groupPartyPK, PeriodPK periodPK, Long balance)
077            throws PersistenceNotNullException {
078        super();
079        constructFields(glAccountPK, groupPartyPK, periodPK, balance);
080    }
081    
082   @Override
083   public GlAccountSummaryFactory getBaseFactoryInstance() {
084        return GlAccountSummaryFactory.getInstance();
085    }
086    
087    @Override
088    public GlAccountSummaryValue clone() {
089        Object result;
090        
091        try {
092            result = super.clone();
093        } catch (CloneNotSupportedException cnse) {
094            // This shouldn't happen, fail when it does.
095            throw new PersistenceCloneException(cnse);
096        }
097        
098        return (GlAccountSummaryValue)result;
099    }
100    
101   @Override
102    public GlAccountSummaryPK getPrimaryKey() {
103        if(_primaryKey == null) {
104            _primaryKey = new GlAccountSummaryPK(entityId);
105        }
106        
107        return _primaryKey;
108    }
109    
110    private void clearHashAndString() {
111        _hashCode = null;
112        _stringValue = null;
113    }
114    
115    @Override
116    public int hashCode() {
117        if(_hashCode == null) {
118            int hashCode = 17;
119            
120            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
121            
122            hashCode = 37 * hashCode + ((glAccountPK != null) ? glAccountPK.hashCode() : 0);
123            hashCode = 37 * hashCode + ((groupPartyPK != null) ? groupPartyPK.hashCode() : 0);
124            hashCode = 37 * hashCode + ((periodPK != null) ? periodPK.hashCode() : 0);
125            hashCode = 37 * hashCode + ((balance != null) ? balance.hashCode() : 0);
126            
127            _hashCode = hashCode;
128        }
129        
130        return _hashCode;
131    }
132    
133    @Override
134    public String toString() {
135        if(_stringValue == null) {
136            StringBuilder stringValue = new StringBuilder("{");
137            
138            stringValue.append("entityId=").append(getEntityId());
139            
140            stringValue.append(", glAccountPK=").append(getGlAccountPK());
141            stringValue.append(", groupPartyPK=").append(getGroupPartyPK());
142            stringValue.append(", periodPK=").append(getPeriodPK());
143            stringValue.append(", balance=").append(getBalance());
144            
145            stringValue.append('}');
146            
147            _stringValue = stringValue.toString();
148        }
149        return _stringValue;
150    }
151    
152    @Override
153    public boolean equals(Object other) {
154        if(this == other)
155            return true;
156        
157        if(!hasIdentity())
158            return false;
159        
160        if(other instanceof  GlAccountSummaryValue) {
161            GlAccountSummaryValue that = (GlAccountSummaryValue)other;
162            
163            if(!that.hasIdentity())
164                return false;
165            
166            Long thisEntityId = getEntityId();
167            Long thatEntityId = that.getEntityId();
168            
169            boolean objectsEqual = thisEntityId.equals(thatEntityId);
170            if(objectsEqual)
171                objectsEqual = objectsEqual && isIdentical(that);
172            
173            return objectsEqual;
174        } else {
175            return false;
176        }
177    }
178    
179    public boolean isIdentical(Object other) {
180        if(other instanceof GlAccountSummaryValue) {
181            GlAccountSummaryValue that = (GlAccountSummaryValue)other;
182            boolean objectsEqual = true;
183            
184            
185            if(objectsEqual) {
186                GlAccountPK thisGlAccountPK = getGlAccountPK();
187                GlAccountPK thatGlAccountPK = that.getGlAccountPK();
188                
189                if(thisGlAccountPK == null) {
190                    objectsEqual = objectsEqual && (thatGlAccountPK == null);
191                } else {
192                    objectsEqual = objectsEqual && thisGlAccountPK.equals(thatGlAccountPK);
193                }
194            }
195            
196            if(objectsEqual) {
197                PartyPK thisGroupPartyPK = getGroupPartyPK();
198                PartyPK thatGroupPartyPK = that.getGroupPartyPK();
199                
200                if(thisGroupPartyPK == null) {
201                    objectsEqual = objectsEqual && (thatGroupPartyPK == null);
202                } else {
203                    objectsEqual = objectsEqual && thisGroupPartyPK.equals(thatGroupPartyPK);
204                }
205            }
206            
207            if(objectsEqual) {
208                PeriodPK thisPeriodPK = getPeriodPK();
209                PeriodPK thatPeriodPK = that.getPeriodPK();
210                
211                if(thisPeriodPK == null) {
212                    objectsEqual = objectsEqual && (thatPeriodPK == null);
213                } else {
214                    objectsEqual = objectsEqual && thisPeriodPK.equals(thatPeriodPK);
215                }
216            }
217            
218            if(objectsEqual) {
219                Long thisBalance = getBalance();
220                Long thatBalance = that.getBalance();
221                
222                if(thisBalance == null) {
223                    objectsEqual = objectsEqual && (thatBalance == null);
224                } else {
225                    objectsEqual = objectsEqual && thisBalance.equals(thatBalance);
226                }
227            }
228            
229            return objectsEqual;
230        } else {
231            return false;
232        }
233    }
234    
235    @Override
236    public boolean hasBeenModified() {
237        return glAccountPKHasBeenModified || groupPartyPKHasBeenModified || periodPKHasBeenModified || balanceHasBeenModified;
238    }
239    
240    @Override
241    public void clearHasBeenModified() {
242        glAccountPKHasBeenModified = false;
243        groupPartyPKHasBeenModified = false;
244        periodPKHasBeenModified = false;
245        balanceHasBeenModified = false;
246    }
247    
248    public GlAccountPK getGlAccountPK() {
249        return glAccountPK;
250    }
251    
252    public void setGlAccountPK(GlAccountPK glAccountPK)
253            throws PersistenceNotNullException {
254        checkForNull(glAccountPK);
255        
256        boolean update = true;
257        
258        if(this.glAccountPK != null) {
259            if(this.glAccountPK.equals(glAccountPK)) {
260                update = false;
261            }
262        } else if(glAccountPK == null) {
263            update = false;
264        }
265        
266        if(update) {
267            this.glAccountPK = glAccountPK;
268            glAccountPKHasBeenModified = true;
269            clearHashAndString();
270        }
271    }
272    
273    public boolean getGlAccountPKHasBeenModified() {
274        return glAccountPKHasBeenModified;
275    }
276    
277    public PartyPK getGroupPartyPK() {
278        return groupPartyPK;
279    }
280    
281    public void setGroupPartyPK(PartyPK groupPartyPK)
282            throws PersistenceNotNullException {
283        checkForNull(groupPartyPK);
284        
285        boolean update = true;
286        
287        if(this.groupPartyPK != null) {
288            if(this.groupPartyPK.equals(groupPartyPK)) {
289                update = false;
290            }
291        } else if(groupPartyPK == null) {
292            update = false;
293        }
294        
295        if(update) {
296            this.groupPartyPK = groupPartyPK;
297            groupPartyPKHasBeenModified = true;
298            clearHashAndString();
299        }
300    }
301    
302    public boolean getGroupPartyPKHasBeenModified() {
303        return groupPartyPKHasBeenModified;
304    }
305    
306    public PeriodPK getPeriodPK() {
307        return periodPK;
308    }
309    
310    public void setPeriodPK(PeriodPK periodPK)
311            throws PersistenceNotNullException {
312        checkForNull(periodPK);
313        
314        boolean update = true;
315        
316        if(this.periodPK != null) {
317            if(this.periodPK.equals(periodPK)) {
318                update = false;
319            }
320        } else if(periodPK == null) {
321            update = false;
322        }
323        
324        if(update) {
325            this.periodPK = periodPK;
326            periodPKHasBeenModified = true;
327            clearHashAndString();
328        }
329    }
330    
331    public boolean getPeriodPKHasBeenModified() {
332        return periodPKHasBeenModified;
333    }
334    
335    public Long getBalance() {
336        return balance;
337    }
338    
339    public void setBalance(Long balance)
340            throws PersistenceNotNullException {
341        checkForNull(balance);
342        
343        boolean update = true;
344        
345        if(this.balance != null) {
346            if(this.balance.equals(balance)) {
347                update = false;
348            }
349        } else if(balance == null) {
350            update = false;
351        }
352        
353        if(update) {
354            this.balance = balance;
355            balanceHasBeenModified = true;
356            clearHashAndString();
357        }
358    }
359    
360    public boolean getBalanceHasBeenModified() {
361        return balanceHasBeenModified;
362    }
363    
364}