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