001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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            _stringValue = "{" + 
144                    "entityId=" + getEntityId() +
145                    ", batchPK=" + getBatchPK() +
146                    ", currencyPK=" + getCurrencyPK() +
147                    ", count=" + getCount() +
148                    ", amount=" + getAmount() +
149                    ", fromTime=" + getFromTime() +
150                    ", thruTime=" + getThruTime() +
151                    "}";
152        }
153        return _stringValue;
154    }
155    
156    @Override
157    public boolean equals(Object other) {
158        if(this == other)
159            return true;
160        
161        if(!hasIdentity())
162            return false;
163        
164        if(other instanceof  OrderBatchValue that) {
165            if(!that.hasIdentity())
166                return false;
167            
168            Long thisEntityId = getEntityId();
169            Long thatEntityId = that.getEntityId();
170            
171            boolean objectsEqual = thisEntityId.equals(thatEntityId);
172            if(objectsEqual)
173                objectsEqual = isIdentical(that);
174            
175            return objectsEqual;
176        } else {
177            return false;
178        }
179    }
180    
181    public boolean isIdentical(Object other) {
182        if(other instanceof OrderBatchValue that) {
183            boolean objectsEqual = true;
184            
185            
186            if(objectsEqual) {
187                BatchPK thisBatchPK = getBatchPK();
188                BatchPK thatBatchPK = that.getBatchPK();
189                
190                if(thisBatchPK == null) {
191                    objectsEqual = objectsEqual && (thatBatchPK == null);
192                } else {
193                    objectsEqual = objectsEqual && thisBatchPK.equals(thatBatchPK);
194                }
195            }
196            
197            if(objectsEqual) {
198                CurrencyPK thisCurrencyPK = getCurrencyPK();
199                CurrencyPK thatCurrencyPK = that.getCurrencyPK();
200                
201                if(thisCurrencyPK == null) {
202                    objectsEqual = objectsEqual && (thatCurrencyPK == null);
203                } else {
204                    objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK);
205                }
206            }
207            
208            if(objectsEqual) {
209                Long thisCount = getCount();
210                Long thatCount = that.getCount();
211                
212                if(thisCount == null) {
213                    objectsEqual = objectsEqual && (thatCount == null);
214                } else {
215                    objectsEqual = objectsEqual && thisCount.equals(thatCount);
216                }
217            }
218            
219            if(objectsEqual) {
220                Long thisAmount = getAmount();
221                Long thatAmount = that.getAmount();
222                
223                if(thisAmount == null) {
224                    objectsEqual = objectsEqual && (thatAmount == null);
225                } else {
226                    objectsEqual = objectsEqual && thisAmount.equals(thatAmount);
227                }
228            }
229            
230            if(objectsEqual) {
231                Long thisFromTime = getFromTime();
232                Long thatFromTime = that.getFromTime();
233                
234                if(thisFromTime == null) {
235                    objectsEqual = objectsEqual && (thatFromTime == null);
236                } else {
237                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
238                }
239            }
240            
241            if(objectsEqual) {
242                Long thisThruTime = getThruTime();
243                Long thatThruTime = that.getThruTime();
244                
245                if(thisThruTime == null) {
246                    objectsEqual = objectsEqual && (thatThruTime == null);
247                } else {
248                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
249                }
250            }
251            
252            return objectsEqual;
253        } else {
254            return false;
255        }
256    }
257    
258    @Override
259    public boolean hasBeenModified() {
260        return batchPKHasBeenModified || currencyPKHasBeenModified || countHasBeenModified || amountHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
261    }
262    
263    @Override
264    public void clearHasBeenModified() {
265        batchPKHasBeenModified = false;
266        currencyPKHasBeenModified = false;
267        countHasBeenModified = false;
268        amountHasBeenModified = false;
269        fromTimeHasBeenModified = false;
270        thruTimeHasBeenModified = false;
271    }
272    
273    public BatchPK getBatchPK() {
274        return batchPK;
275    }
276    
277    public void setBatchPK(BatchPK batchPK)
278            throws PersistenceNotNullException {
279        checkForNull(batchPK);
280        
281        boolean update = true;
282        
283        if(this.batchPK != null) {
284            if(this.batchPK.equals(batchPK)) {
285                update = false;
286            }
287        } else if(batchPK == null) {
288            update = false;
289        }
290        
291        if(update) {
292            this.batchPK = batchPK;
293            batchPKHasBeenModified = true;
294            clearHashAndString();
295        }
296    }
297    
298    public boolean getBatchPKHasBeenModified() {
299        return batchPKHasBeenModified;
300    }
301    
302    public CurrencyPK getCurrencyPK() {
303        return currencyPK;
304    }
305    
306    public void setCurrencyPK(CurrencyPK currencyPK)
307            throws PersistenceNotNullException {
308        checkForNull(currencyPK);
309        
310        boolean update = true;
311        
312        if(this.currencyPK != null) {
313            if(this.currencyPK.equals(currencyPK)) {
314                update = false;
315            }
316        } else if(currencyPK == null) {
317            update = false;
318        }
319        
320        if(update) {
321            this.currencyPK = currencyPK;
322            currencyPKHasBeenModified = true;
323            clearHashAndString();
324        }
325    }
326    
327    public boolean getCurrencyPKHasBeenModified() {
328        return currencyPKHasBeenModified;
329    }
330    
331    public Long getCount() {
332        return count;
333    }
334    
335    public void setCount(Long count) {
336        boolean update = true;
337        
338        if(this.count != null) {
339            if(this.count.equals(count)) {
340                update = false;
341            }
342        } else if(count == null) {
343            update = false;
344        }
345        
346        if(update) {
347            this.count = count;
348            countHasBeenModified = true;
349            clearHashAndString();
350        }
351    }
352    
353    public boolean getCountHasBeenModified() {
354        return countHasBeenModified;
355    }
356    
357    public Long getAmount() {
358        return amount;
359    }
360    
361    public void setAmount(Long amount) {
362        boolean update = true;
363        
364        if(this.amount != null) {
365            if(this.amount.equals(amount)) {
366                update = false;
367            }
368        } else if(amount == null) {
369            update = false;
370        }
371        
372        if(update) {
373            this.amount = amount;
374            amountHasBeenModified = true;
375            clearHashAndString();
376        }
377    }
378    
379    public boolean getAmountHasBeenModified() {
380        return amountHasBeenModified;
381    }
382    
383    public Long getFromTime() {
384        return fromTime;
385    }
386    
387    public void setFromTime(Long fromTime)
388            throws PersistenceNotNullException {
389        checkForNull(fromTime);
390        
391        boolean update = true;
392        
393        if(this.fromTime != null) {
394            if(this.fromTime.equals(fromTime)) {
395                update = false;
396            }
397        } else if(fromTime == null) {
398            update = false;
399        }
400        
401        if(update) {
402            this.fromTime = fromTime;
403            fromTimeHasBeenModified = true;
404            clearHashAndString();
405        }
406    }
407    
408    public boolean getFromTimeHasBeenModified() {
409        return fromTimeHasBeenModified;
410    }
411    
412    public Long getThruTime() {
413        return thruTime;
414    }
415    
416    public void setThruTime(Long thruTime)
417            throws PersistenceNotNullException {
418        checkForNull(thruTime);
419        
420        boolean update = true;
421        
422        if(this.thruTime != null) {
423            if(this.thruTime.equals(thruTime)) {
424                update = false;
425            }
426        } else if(thruTime == null) {
427            update = false;
428        }
429        
430        if(update) {
431            this.thruTime = thruTime;
432            thruTimeHasBeenModified = true;
433            clearHashAndString();
434        }
435    }
436    
437    public boolean getThruTimeHasBeenModified() {
438        return thruTimeHasBeenModified;
439    }
440    
441}