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 * TransactionStatusValue.java
021 */
022
023package com.echothree.model.data.accounting.server.value;
024
025import com.echothree.model.data.accounting.common.pk.TransactionStatusPK;
026
027import com.echothree.model.data.accounting.server.factory.TransactionStatusFactory;
028
029import com.echothree.model.data.accounting.common.pk.TransactionPK;
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
038public class TransactionStatusValue
039        extends BaseValue<TransactionStatusPK>
040        implements Cloneable, Serializable {
041    
042    private TransactionPK transactionPK;
043    private boolean transactionPKHasBeenModified = false;
044    private Integer transactionGlEntrySequence;
045    private boolean transactionGlEntrySequenceHasBeenModified = false;
046    
047    private transient Integer _hashCode = null;
048    private transient String _stringValue = null;
049    
050    private void constructFields(TransactionPK transactionPK, Integer transactionGlEntrySequence)
051            throws PersistenceNotNullException {
052        checkForNull(transactionPK);
053        this.transactionPK = transactionPK;
054        checkForNull(transactionGlEntrySequence);
055        this.transactionGlEntrySequence = transactionGlEntrySequence;
056    }
057    
058    /** Creates a new instance of TransactionStatusValue */
059    public TransactionStatusValue(TransactionStatusPK transactionStatusPK, TransactionPK transactionPK, Integer transactionGlEntrySequence)
060            throws PersistenceNotNullException {
061        super(transactionStatusPK);
062        constructFields(transactionPK, transactionGlEntrySequence);
063    }
064    
065    /** Creates a new instance of TransactionStatusValue */
066    public TransactionStatusValue(TransactionPK transactionPK, Integer transactionGlEntrySequence)
067            throws PersistenceNotNullException {
068        super();
069        constructFields(transactionPK, transactionGlEntrySequence);
070    }
071    
072   @Override
073   public TransactionStatusFactory getBaseFactoryInstance() {
074        return TransactionStatusFactory.getInstance();
075    }
076    
077    @Override
078    public TransactionStatusValue clone() {
079        Object result;
080        
081        try {
082            result = super.clone();
083        } catch (CloneNotSupportedException cnse) {
084            // This shouldn't happen, fail when it does.
085            throw new PersistenceCloneException(cnse);
086        }
087        
088        return (TransactionStatusValue)result;
089    }
090    
091   @Override
092    public TransactionStatusPK getPrimaryKey() {
093        if(_primaryKey == null) {
094            _primaryKey = new TransactionStatusPK(entityId);
095        }
096        
097        return _primaryKey;
098    }
099    
100    private void clearHashAndString() {
101        _hashCode = null;
102        _stringValue = null;
103    }
104    
105    @Override
106    public int hashCode() {
107        if(_hashCode == null) {
108            int hashCode = 17;
109            
110            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
111            
112            hashCode = 37 * hashCode + ((transactionPK != null) ? transactionPK.hashCode() : 0);
113            hashCode = 37 * hashCode + ((transactionGlEntrySequence != null) ? transactionGlEntrySequence.hashCode() : 0);
114            
115            _hashCode = hashCode;
116        }
117        
118        return _hashCode;
119    }
120    
121    @Override
122    public String toString() {
123        if(_stringValue == null) {
124            StringBuilder stringValue = new StringBuilder("{");
125            
126            stringValue.append("entityId=").append(getEntityId());
127            
128            stringValue.append(", transactionPK=").append(getTransactionPK());
129            stringValue.append(", transactionGlEntrySequence=").append(getTransactionGlEntrySequence());
130            
131            stringValue.append('}');
132            
133            _stringValue = stringValue.toString();
134        }
135        return _stringValue;
136    }
137    
138    @Override
139    public boolean equals(Object other) {
140        if(this == other)
141            return true;
142        
143        if(!hasIdentity())
144            return false;
145        
146        if(other instanceof  TransactionStatusValue) {
147            TransactionStatusValue that = (TransactionStatusValue)other;
148            
149            if(!that.hasIdentity())
150                return false;
151            
152            Long thisEntityId = getEntityId();
153            Long thatEntityId = that.getEntityId();
154            
155            boolean objectsEqual = thisEntityId.equals(thatEntityId);
156            if(objectsEqual)
157                objectsEqual = objectsEqual && isIdentical(that);
158            
159            return objectsEqual;
160        } else {
161            return false;
162        }
163    }
164    
165    public boolean isIdentical(Object other) {
166        if(other instanceof TransactionStatusValue) {
167            TransactionStatusValue that = (TransactionStatusValue)other;
168            boolean objectsEqual = true;
169            
170            
171            if(objectsEqual) {
172                TransactionPK thisTransactionPK = getTransactionPK();
173                TransactionPK thatTransactionPK = that.getTransactionPK();
174                
175                if(thisTransactionPK == null) {
176                    objectsEqual = objectsEqual && (thatTransactionPK == null);
177                } else {
178                    objectsEqual = objectsEqual && thisTransactionPK.equals(thatTransactionPK);
179                }
180            }
181            
182            if(objectsEqual) {
183                Integer thisTransactionGlEntrySequence = getTransactionGlEntrySequence();
184                Integer thatTransactionGlEntrySequence = that.getTransactionGlEntrySequence();
185                
186                if(thisTransactionGlEntrySequence == null) {
187                    objectsEqual = objectsEqual && (thatTransactionGlEntrySequence == null);
188                } else {
189                    objectsEqual = objectsEqual && thisTransactionGlEntrySequence.equals(thatTransactionGlEntrySequence);
190                }
191            }
192            
193            return objectsEqual;
194        } else {
195            return false;
196        }
197    }
198    
199    @Override
200    public boolean hasBeenModified() {
201        return transactionPKHasBeenModified || transactionGlEntrySequenceHasBeenModified;
202    }
203    
204    @Override
205    public void clearHasBeenModified() {
206        transactionPKHasBeenModified = false;
207        transactionGlEntrySequenceHasBeenModified = false;
208    }
209    
210    public TransactionPK getTransactionPK() {
211        return transactionPK;
212    }
213    
214    public void setTransactionPK(TransactionPK transactionPK)
215            throws PersistenceNotNullException {
216        checkForNull(transactionPK);
217        
218        boolean update = true;
219        
220        if(this.transactionPK != null) {
221            if(this.transactionPK.equals(transactionPK)) {
222                update = false;
223            }
224        } else if(transactionPK == null) {
225            update = false;
226        }
227        
228        if(update) {
229            this.transactionPK = transactionPK;
230            transactionPKHasBeenModified = true;
231            clearHashAndString();
232        }
233    }
234    
235    public boolean getTransactionPKHasBeenModified() {
236        return transactionPKHasBeenModified;
237    }
238    
239    public Integer getTransactionGlEntrySequence() {
240        return transactionGlEntrySequence;
241    }
242    
243    public void setTransactionGlEntrySequence(Integer transactionGlEntrySequence)
244            throws PersistenceNotNullException {
245        checkForNull(transactionGlEntrySequence);
246        
247        boolean update = true;
248        
249        if(this.transactionGlEntrySequence != null) {
250            if(this.transactionGlEntrySequence.equals(transactionGlEntrySequence)) {
251                update = false;
252            }
253        } else if(transactionGlEntrySequence == null) {
254            update = false;
255        }
256        
257        if(update) {
258            this.transactionGlEntrySequence = transactionGlEntrySequence;
259            transactionGlEntrySequenceHasBeenModified = true;
260            clearHashAndString();
261        }
262    }
263    
264    public boolean getTransactionGlEntrySequenceHasBeenModified() {
265        return transactionGlEntrySequenceHasBeenModified;
266    }
267    
268}