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 * FinancialAccountStatusValue.java
021 */
022
023package com.echothree.model.data.financial.server.value;
024
025import com.echothree.model.data.financial.common.pk.FinancialAccountStatusPK;
026
027import com.echothree.model.data.financial.server.factory.FinancialAccountStatusFactory;
028
029import com.echothree.model.data.financial.common.pk.FinancialAccountPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038import javax.annotation.Nonnull;
039import javax.annotation.Nullable;
040
041public class FinancialAccountStatusValue
042        extends BaseValue<FinancialAccountStatusPK>
043        implements Cloneable, Serializable {
044    
045    private FinancialAccountPK financialAccountPK;
046    private boolean financialAccountPKHasBeenModified = false;
047    private Long actualBalance;
048    private boolean actualBalanceHasBeenModified = false;
049    private Long availableBalance;
050    private boolean availableBalanceHasBeenModified = false;
051    
052    private transient Integer _hashCode = null;
053    private transient String _stringValue = null;
054    
055    private void constructFields(FinancialAccountPK financialAccountPK, Long actualBalance, Long availableBalance)
056            throws PersistenceNotNullException {
057        checkForNull(financialAccountPK);
058        this.financialAccountPK = financialAccountPK;
059        checkForNull(actualBalance);
060        this.actualBalance = actualBalance;
061        checkForNull(availableBalance);
062        this.availableBalance = availableBalance;
063    }
064    
065    /** Creates a new instance of FinancialAccountStatusValue */
066    public FinancialAccountStatusValue(FinancialAccountStatusPK financialAccountStatusPK, FinancialAccountPK financialAccountPK, Long actualBalance, Long availableBalance)
067            throws PersistenceNotNullException {
068        super(financialAccountStatusPK);
069        constructFields(financialAccountPK, actualBalance, availableBalance);
070    }
071    
072    /** Creates a new instance of FinancialAccountStatusValue */
073    public FinancialAccountStatusValue(FinancialAccountPK financialAccountPK, Long actualBalance, Long availableBalance)
074            throws PersistenceNotNullException {
075        super();
076        constructFields(financialAccountPK, actualBalance, availableBalance);
077    }
078    
079    @Override
080    @Nonnull
081    public FinancialAccountStatusFactory getBaseFactoryInstance() {
082        return FinancialAccountStatusFactory.getInstance();
083    }
084    
085    @Override
086    @Nonnull
087    public FinancialAccountStatusValue clone() {
088        Object result;
089        
090        try {
091            result = super.clone();
092        } catch (CloneNotSupportedException cnse) {
093            // This shouldn't happen, fail when it does.
094            throw new PersistenceCloneException(cnse);
095        }
096        
097        return (FinancialAccountStatusValue)result;
098    }
099    
100    @Override
101    @Nonnull
102    public FinancialAccountStatusPK getPrimaryKey() {
103        if(_primaryKey == null) {
104            _primaryKey = new FinancialAccountStatusPK(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 + ((financialAccountPK != null) ? financialAccountPK.hashCode() : 0);
123            hashCode = 37 * hashCode + ((actualBalance != null) ? actualBalance.hashCode() : 0);
124            hashCode = 37 * hashCode + ((availableBalance != null) ? availableBalance.hashCode() : 0);
125            
126            _hashCode = hashCode;
127        }
128        
129        return _hashCode;
130    }
131    
132    @Override
133    @Nonnull
134    public String toString() {
135        if(_stringValue == null) {
136            _stringValue = "{" + 
137                    "entityId=" + getEntityId() +
138                    ", financialAccountPK=" + getFinancialAccountPK() +
139                    ", actualBalance=" + getActualBalance() +
140                    ", availableBalance=" + getAvailableBalance() +
141                    "}";
142        }
143        return _stringValue;
144    }
145    
146    @Override
147    public boolean equals(Object other) {
148        if(this == other)
149            return true;
150        
151        if(!hasIdentity())
152            return false;
153        
154        if(other instanceof  FinancialAccountStatusValue that) {
155            if(!that.hasIdentity())
156                return false;
157            
158            Long thisEntityId = getEntityId();
159            Long thatEntityId = that.getEntityId();
160            
161            boolean objectsEqual = thisEntityId.equals(thatEntityId);
162            if(objectsEqual)
163                objectsEqual = isIdentical(that);
164            
165            return objectsEqual;
166        } else {
167            return false;
168        }
169    }
170    
171    public boolean isIdentical(Object other) {
172        if(other instanceof FinancialAccountStatusValue that) {
173            boolean objectsEqual = true;
174            
175            
176            if(objectsEqual) {
177                FinancialAccountPK thisFinancialAccountPK = getFinancialAccountPK();
178                FinancialAccountPK thatFinancialAccountPK = that.getFinancialAccountPK();
179                
180                if(thisFinancialAccountPK == null) {
181                    objectsEqual = objectsEqual && (thatFinancialAccountPK == null);
182                } else {
183                    objectsEqual = objectsEqual && thisFinancialAccountPK.equals(thatFinancialAccountPK);
184                }
185            }
186            
187            if(objectsEqual) {
188                Long thisActualBalance = getActualBalance();
189                Long thatActualBalance = that.getActualBalance();
190                
191                if(thisActualBalance == null) {
192                    objectsEqual = objectsEqual && (thatActualBalance == null);
193                } else {
194                    objectsEqual = objectsEqual && thisActualBalance.equals(thatActualBalance);
195                }
196            }
197            
198            if(objectsEqual) {
199                Long thisAvailableBalance = getAvailableBalance();
200                Long thatAvailableBalance = that.getAvailableBalance();
201                
202                if(thisAvailableBalance == null) {
203                    objectsEqual = objectsEqual && (thatAvailableBalance == null);
204                } else {
205                    objectsEqual = objectsEqual && thisAvailableBalance.equals(thatAvailableBalance);
206                }
207            }
208            
209            return objectsEqual;
210        } else {
211            return false;
212        }
213    }
214    
215    @Override
216    public boolean hasBeenModified() {
217        return financialAccountPKHasBeenModified || actualBalanceHasBeenModified || availableBalanceHasBeenModified;
218    }
219    
220    @Override
221    public void clearHasBeenModified() {
222        financialAccountPKHasBeenModified = false;
223        actualBalanceHasBeenModified = false;
224        availableBalanceHasBeenModified = false;
225    }
226    
227    @Nonnull
228    public FinancialAccountPK getFinancialAccountPK() {
229        return financialAccountPK;
230    }
231    
232    public void setFinancialAccountPK(@Nonnull FinancialAccountPK financialAccountPK)
233            throws PersistenceNotNullException {
234        checkForNull(financialAccountPK);
235        
236        boolean update = true;
237        
238        if(this.financialAccountPK != null) {
239            if(this.financialAccountPK.equals(financialAccountPK)) {
240                update = false;
241            }
242        } else if(financialAccountPK == null) {
243            update = false;
244        }
245        
246        if(update) {
247            this.financialAccountPK = financialAccountPK;
248            financialAccountPKHasBeenModified = true;
249            clearHashAndString();
250        }
251    }
252    
253    public boolean getFinancialAccountPKHasBeenModified() {
254        return financialAccountPKHasBeenModified;
255    }
256    
257    @Nonnull
258    public Long getActualBalance() {
259        return actualBalance;
260    }
261    
262    public void setActualBalance(@Nonnull Long actualBalance)
263            throws PersistenceNotNullException {
264        checkForNull(actualBalance);
265        
266        boolean update = true;
267        
268        if(this.actualBalance != null) {
269            if(this.actualBalance.equals(actualBalance)) {
270                update = false;
271            }
272        } else if(actualBalance == null) {
273            update = false;
274        }
275        
276        if(update) {
277            this.actualBalance = actualBalance;
278            actualBalanceHasBeenModified = true;
279            clearHashAndString();
280        }
281    }
282    
283    public boolean getActualBalanceHasBeenModified() {
284        return actualBalanceHasBeenModified;
285    }
286    
287    @Nonnull
288    public Long getAvailableBalance() {
289        return availableBalance;
290    }
291    
292    public void setAvailableBalance(@Nonnull Long availableBalance)
293            throws PersistenceNotNullException {
294        checkForNull(availableBalance);
295        
296        boolean update = true;
297        
298        if(this.availableBalance != null) {
299            if(this.availableBalance.equals(availableBalance)) {
300                update = false;
301            }
302        } else if(availableBalance == null) {
303            update = false;
304        }
305        
306        if(update) {
307            this.availableBalance = availableBalance;
308            availableBalanceHasBeenModified = true;
309            clearHashAndString();
310        }
311    }
312    
313    public boolean getAvailableBalanceHasBeenModified() {
314        return availableBalanceHasBeenModified;
315    }
316    
317}