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 * TransactionDetailValue.java
021 */
022
023package com.echothree.model.data.accounting.server.value;
024
025import com.echothree.model.data.accounting.common.pk.TransactionDetailPK;
026
027import com.echothree.model.data.accounting.server.factory.TransactionDetailFactory;
028
029import com.echothree.model.data.accounting.common.pk.TransactionPK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.accounting.common.pk.TransactionGroupPK;
032import com.echothree.model.data.accounting.common.pk.TransactionTypePK;
033
034import com.echothree.util.common.exception.PersistenceCloneException;
035import com.echothree.util.common.exception.PersistenceNotNullException;
036
037import com.echothree.util.server.persistence.BaseValue;
038
039import java.io.Serializable;
040
041public class TransactionDetailValue
042        extends BaseValue<TransactionDetailPK>
043        implements Cloneable, Serializable {
044    
045    private TransactionPK transactionPK;
046    private boolean transactionPKHasBeenModified = false;
047    private String transactionName;
048    private boolean transactionNameHasBeenModified = false;
049    private PartyPK groupPartyPK;
050    private boolean groupPartyPKHasBeenModified = false;
051    private TransactionGroupPK transactionGroupPK;
052    private boolean transactionGroupPKHasBeenModified = false;
053    private TransactionTypePK transactionTypePK;
054    private boolean transactionTypePKHasBeenModified = false;
055    private Long postingTime;
056    private boolean postingTimeHasBeenModified = false;
057    private Long fromTime;
058    private boolean fromTimeHasBeenModified = false;
059    private Long thruTime;
060    private boolean thruTimeHasBeenModified = false;
061    
062    private transient Integer _hashCode = null;
063    private transient String _stringValue = null;
064    
065    private void constructFields(TransactionPK transactionPK, String transactionName, PartyPK groupPartyPK, TransactionGroupPK transactionGroupPK, TransactionTypePK transactionTypePK, Long postingTime, Long fromTime, Long thruTime)
066            throws PersistenceNotNullException {
067        checkForNull(transactionPK);
068        this.transactionPK = transactionPK;
069        checkForNull(transactionName);
070        this.transactionName = transactionName;
071        this.groupPartyPK = groupPartyPK;
072        checkForNull(transactionGroupPK);
073        this.transactionGroupPK = transactionGroupPK;
074        checkForNull(transactionTypePK);
075        this.transactionTypePK = transactionTypePK;
076        checkForNull(postingTime);
077        this.postingTime = postingTime;
078        checkForNull(fromTime);
079        this.fromTime = fromTime;
080        checkForNull(thruTime);
081        this.thruTime = thruTime;
082    }
083    
084    /** Creates a new instance of TransactionDetailValue */
085    public TransactionDetailValue(TransactionDetailPK transactionDetailPK, TransactionPK transactionPK, String transactionName, PartyPK groupPartyPK, TransactionGroupPK transactionGroupPK, TransactionTypePK transactionTypePK, Long postingTime, Long fromTime, Long thruTime)
086            throws PersistenceNotNullException {
087        super(transactionDetailPK);
088        constructFields(transactionPK, transactionName, groupPartyPK, transactionGroupPK, transactionTypePK, postingTime, fromTime, thruTime);
089    }
090    
091    /** Creates a new instance of TransactionDetailValue */
092    public TransactionDetailValue(TransactionPK transactionPK, String transactionName, PartyPK groupPartyPK, TransactionGroupPK transactionGroupPK, TransactionTypePK transactionTypePK, Long postingTime, Long fromTime, Long thruTime)
093            throws PersistenceNotNullException {
094        super();
095        constructFields(transactionPK, transactionName, groupPartyPK, transactionGroupPK, transactionTypePK, postingTime, fromTime, thruTime);
096    }
097    
098   @Override
099   public TransactionDetailFactory getBaseFactoryInstance() {
100        return TransactionDetailFactory.getInstance();
101    }
102    
103    @Override
104    public TransactionDetailValue clone() {
105        Object result;
106        
107        try {
108            result = super.clone();
109        } catch (CloneNotSupportedException cnse) {
110            // This shouldn't happen, fail when it does.
111            throw new PersistenceCloneException(cnse);
112        }
113        
114        return (TransactionDetailValue)result;
115    }
116    
117   @Override
118    public TransactionDetailPK getPrimaryKey() {
119        if(_primaryKey == null) {
120            _primaryKey = new TransactionDetailPK(entityId);
121        }
122        
123        return _primaryKey;
124    }
125    
126    private void clearHashAndString() {
127        _hashCode = null;
128        _stringValue = null;
129    }
130    
131    @Override
132    public int hashCode() {
133        if(_hashCode == null) {
134            int hashCode = 17;
135            
136            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
137            
138            hashCode = 37 * hashCode + ((transactionPK != null) ? transactionPK.hashCode() : 0);
139            hashCode = 37 * hashCode + ((transactionName != null) ? transactionName.hashCode() : 0);
140            hashCode = 37 * hashCode + ((groupPartyPK != null) ? groupPartyPK.hashCode() : 0);
141            hashCode = 37 * hashCode + ((transactionGroupPK != null) ? transactionGroupPK.hashCode() : 0);
142            hashCode = 37 * hashCode + ((transactionTypePK != null) ? transactionTypePK.hashCode() : 0);
143            hashCode = 37 * hashCode + ((postingTime != null) ? postingTime.hashCode() : 0);
144            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
145            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
146            
147            _hashCode = hashCode;
148        }
149        
150        return _hashCode;
151    }
152    
153    @Override
154    public String toString() {
155        if(_stringValue == null) {
156            StringBuilder stringValue = new StringBuilder("{");
157            
158            stringValue.append("entityId=").append(getEntityId());
159            
160            stringValue.append(", transactionPK=").append(getTransactionPK());
161            stringValue.append(", transactionName=").append(getTransactionName());
162            stringValue.append(", groupPartyPK=").append(getGroupPartyPK());
163            stringValue.append(", transactionGroupPK=").append(getTransactionGroupPK());
164            stringValue.append(", transactionTypePK=").append(getTransactionTypePK());
165            stringValue.append(", postingTime=").append(getPostingTime());
166            stringValue.append(", fromTime=").append(getFromTime());
167            stringValue.append(", thruTime=").append(getThruTime());
168            
169            stringValue.append('}');
170            
171            _stringValue = stringValue.toString();
172        }
173        return _stringValue;
174    }
175    
176    @Override
177    public boolean equals(Object other) {
178        if(this == other)
179            return true;
180        
181        if(!hasIdentity())
182            return false;
183        
184        if(other instanceof  TransactionDetailValue) {
185            TransactionDetailValue that = (TransactionDetailValue)other;
186            
187            if(!that.hasIdentity())
188                return false;
189            
190            Long thisEntityId = getEntityId();
191            Long thatEntityId = that.getEntityId();
192            
193            boolean objectsEqual = thisEntityId.equals(thatEntityId);
194            if(objectsEqual)
195                objectsEqual = objectsEqual && isIdentical(that);
196            
197            return objectsEqual;
198        } else {
199            return false;
200        }
201    }
202    
203    public boolean isIdentical(Object other) {
204        if(other instanceof TransactionDetailValue) {
205            TransactionDetailValue that = (TransactionDetailValue)other;
206            boolean objectsEqual = true;
207            
208            
209            if(objectsEqual) {
210                TransactionPK thisTransactionPK = getTransactionPK();
211                TransactionPK thatTransactionPK = that.getTransactionPK();
212                
213                if(thisTransactionPK == null) {
214                    objectsEqual = objectsEqual && (thatTransactionPK == null);
215                } else {
216                    objectsEqual = objectsEqual && thisTransactionPK.equals(thatTransactionPK);
217                }
218            }
219            
220            if(objectsEqual) {
221                String thisTransactionName = getTransactionName();
222                String thatTransactionName = that.getTransactionName();
223                
224                if(thisTransactionName == null) {
225                    objectsEqual = objectsEqual && (thatTransactionName == null);
226                } else {
227                    objectsEqual = objectsEqual && thisTransactionName.equals(thatTransactionName);
228                }
229            }
230            
231            if(objectsEqual) {
232                PartyPK thisGroupPartyPK = getGroupPartyPK();
233                PartyPK thatGroupPartyPK = that.getGroupPartyPK();
234                
235                if(thisGroupPartyPK == null) {
236                    objectsEqual = objectsEqual && (thatGroupPartyPK == null);
237                } else {
238                    objectsEqual = objectsEqual && thisGroupPartyPK.equals(thatGroupPartyPK);
239                }
240            }
241            
242            if(objectsEqual) {
243                TransactionGroupPK thisTransactionGroupPK = getTransactionGroupPK();
244                TransactionGroupPK thatTransactionGroupPK = that.getTransactionGroupPK();
245                
246                if(thisTransactionGroupPK == null) {
247                    objectsEqual = objectsEqual && (thatTransactionGroupPK == null);
248                } else {
249                    objectsEqual = objectsEqual && thisTransactionGroupPK.equals(thatTransactionGroupPK);
250                }
251            }
252            
253            if(objectsEqual) {
254                TransactionTypePK thisTransactionTypePK = getTransactionTypePK();
255                TransactionTypePK thatTransactionTypePK = that.getTransactionTypePK();
256                
257                if(thisTransactionTypePK == null) {
258                    objectsEqual = objectsEqual && (thatTransactionTypePK == null);
259                } else {
260                    objectsEqual = objectsEqual && thisTransactionTypePK.equals(thatTransactionTypePK);
261                }
262            }
263            
264            if(objectsEqual) {
265                Long thisPostingTime = getPostingTime();
266                Long thatPostingTime = that.getPostingTime();
267                
268                if(thisPostingTime == null) {
269                    objectsEqual = objectsEqual && (thatPostingTime == null);
270                } else {
271                    objectsEqual = objectsEqual && thisPostingTime.equals(thatPostingTime);
272                }
273            }
274            
275            if(objectsEqual) {
276                Long thisFromTime = getFromTime();
277                Long thatFromTime = that.getFromTime();
278                
279                if(thisFromTime == null) {
280                    objectsEqual = objectsEqual && (thatFromTime == null);
281                } else {
282                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
283                }
284            }
285            
286            if(objectsEqual) {
287                Long thisThruTime = getThruTime();
288                Long thatThruTime = that.getThruTime();
289                
290                if(thisThruTime == null) {
291                    objectsEqual = objectsEqual && (thatThruTime == null);
292                } else {
293                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
294                }
295            }
296            
297            return objectsEqual;
298        } else {
299            return false;
300        }
301    }
302    
303    @Override
304    public boolean hasBeenModified() {
305        return transactionPKHasBeenModified || transactionNameHasBeenModified || groupPartyPKHasBeenModified || transactionGroupPKHasBeenModified || transactionTypePKHasBeenModified || postingTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
306    }
307    
308    @Override
309    public void clearHasBeenModified() {
310        transactionPKHasBeenModified = false;
311        transactionNameHasBeenModified = false;
312        groupPartyPKHasBeenModified = false;
313        transactionGroupPKHasBeenModified = false;
314        transactionTypePKHasBeenModified = false;
315        postingTimeHasBeenModified = false;
316        fromTimeHasBeenModified = false;
317        thruTimeHasBeenModified = false;
318    }
319    
320    public TransactionPK getTransactionPK() {
321        return transactionPK;
322    }
323    
324    public void setTransactionPK(TransactionPK transactionPK)
325            throws PersistenceNotNullException {
326        checkForNull(transactionPK);
327        
328        boolean update = true;
329        
330        if(this.transactionPK != null) {
331            if(this.transactionPK.equals(transactionPK)) {
332                update = false;
333            }
334        } else if(transactionPK == null) {
335            update = false;
336        }
337        
338        if(update) {
339            this.transactionPK = transactionPK;
340            transactionPKHasBeenModified = true;
341            clearHashAndString();
342        }
343    }
344    
345    public boolean getTransactionPKHasBeenModified() {
346        return transactionPKHasBeenModified;
347    }
348    
349    public String getTransactionName() {
350        return transactionName;
351    }
352    
353    public void setTransactionName(String transactionName)
354            throws PersistenceNotNullException {
355        checkForNull(transactionName);
356        
357        boolean update = true;
358        
359        if(this.transactionName != null) {
360            if(this.transactionName.equals(transactionName)) {
361                update = false;
362            }
363        } else if(transactionName == null) {
364            update = false;
365        }
366        
367        if(update) {
368            this.transactionName = transactionName;
369            transactionNameHasBeenModified = true;
370            clearHashAndString();
371        }
372    }
373    
374    public boolean getTransactionNameHasBeenModified() {
375        return transactionNameHasBeenModified;
376    }
377    
378    public PartyPK getGroupPartyPK() {
379        return groupPartyPK;
380    }
381    
382    public void setGroupPartyPK(PartyPK groupPartyPK) {
383        boolean update = true;
384        
385        if(this.groupPartyPK != null) {
386            if(this.groupPartyPK.equals(groupPartyPK)) {
387                update = false;
388            }
389        } else if(groupPartyPK == null) {
390            update = false;
391        }
392        
393        if(update) {
394            this.groupPartyPK = groupPartyPK;
395            groupPartyPKHasBeenModified = true;
396            clearHashAndString();
397        }
398    }
399    
400    public boolean getGroupPartyPKHasBeenModified() {
401        return groupPartyPKHasBeenModified;
402    }
403    
404    public TransactionGroupPK getTransactionGroupPK() {
405        return transactionGroupPK;
406    }
407    
408    public void setTransactionGroupPK(TransactionGroupPK transactionGroupPK)
409            throws PersistenceNotNullException {
410        checkForNull(transactionGroupPK);
411        
412        boolean update = true;
413        
414        if(this.transactionGroupPK != null) {
415            if(this.transactionGroupPK.equals(transactionGroupPK)) {
416                update = false;
417            }
418        } else if(transactionGroupPK == null) {
419            update = false;
420        }
421        
422        if(update) {
423            this.transactionGroupPK = transactionGroupPK;
424            transactionGroupPKHasBeenModified = true;
425            clearHashAndString();
426        }
427    }
428    
429    public boolean getTransactionGroupPKHasBeenModified() {
430        return transactionGroupPKHasBeenModified;
431    }
432    
433    public TransactionTypePK getTransactionTypePK() {
434        return transactionTypePK;
435    }
436    
437    public void setTransactionTypePK(TransactionTypePK transactionTypePK)
438            throws PersistenceNotNullException {
439        checkForNull(transactionTypePK);
440        
441        boolean update = true;
442        
443        if(this.transactionTypePK != null) {
444            if(this.transactionTypePK.equals(transactionTypePK)) {
445                update = false;
446            }
447        } else if(transactionTypePK == null) {
448            update = false;
449        }
450        
451        if(update) {
452            this.transactionTypePK = transactionTypePK;
453            transactionTypePKHasBeenModified = true;
454            clearHashAndString();
455        }
456    }
457    
458    public boolean getTransactionTypePKHasBeenModified() {
459        return transactionTypePKHasBeenModified;
460    }
461    
462    public Long getPostingTime() {
463        return postingTime;
464    }
465    
466    public void setPostingTime(Long postingTime)
467            throws PersistenceNotNullException {
468        checkForNull(postingTime);
469        
470        boolean update = true;
471        
472        if(this.postingTime != null) {
473            if(this.postingTime.equals(postingTime)) {
474                update = false;
475            }
476        } else if(postingTime == null) {
477            update = false;
478        }
479        
480        if(update) {
481            this.postingTime = postingTime;
482            postingTimeHasBeenModified = true;
483            clearHashAndString();
484        }
485    }
486    
487    public boolean getPostingTimeHasBeenModified() {
488        return postingTimeHasBeenModified;
489    }
490    
491    public Long getFromTime() {
492        return fromTime;
493    }
494    
495    public void setFromTime(Long fromTime)
496            throws PersistenceNotNullException {
497        checkForNull(fromTime);
498        
499        boolean update = true;
500        
501        if(this.fromTime != null) {
502            if(this.fromTime.equals(fromTime)) {
503                update = false;
504            }
505        } else if(fromTime == null) {
506            update = false;
507        }
508        
509        if(update) {
510            this.fromTime = fromTime;
511            fromTimeHasBeenModified = true;
512            clearHashAndString();
513        }
514    }
515    
516    public boolean getFromTimeHasBeenModified() {
517        return fromTimeHasBeenModified;
518    }
519    
520    public Long getThruTime() {
521        return thruTime;
522    }
523    
524    public void setThruTime(Long thruTime)
525            throws PersistenceNotNullException {
526        checkForNull(thruTime);
527        
528        boolean update = true;
529        
530        if(this.thruTime != null) {
531            if(this.thruTime.equals(thruTime)) {
532                update = false;
533            }
534        } else if(thruTime == null) {
535            update = false;
536        }
537        
538        if(update) {
539            this.thruTime = thruTime;
540            thruTimeHasBeenModified = true;
541            clearHashAndString();
542        }
543    }
544    
545    public boolean getThruTimeHasBeenModified() {
546        return thruTimeHasBeenModified;
547    }
548    
549}