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