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 * SalesOrderLineValue.java
021 */
022
023package com.echothree.model.data.sales.server.value;
024
025import com.echothree.model.data.sales.common.pk.SalesOrderLinePK;
026
027import com.echothree.model.data.sales.server.factory.SalesOrderLineFactory;
028
029import com.echothree.model.data.order.common.pk.OrderLinePK;
030import com.echothree.model.data.offer.common.pk.OfferUsePK;
031import com.echothree.model.data.associate.common.pk.AssociateReferralPK;
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 SalesOrderLineValue
041        extends BaseValue<SalesOrderLinePK>
042        implements Cloneable, Serializable {
043    
044    private OrderLinePK orderLinePK;
045    private boolean orderLinePKHasBeenModified = false;
046    private OfferUsePK offerUsePK;
047    private boolean offerUsePKHasBeenModified = false;
048    private AssociateReferralPK associateReferralPK;
049    private boolean associateReferralPKHasBeenModified = false;
050    private Long fromTime;
051    private boolean fromTimeHasBeenModified = false;
052    private Long thruTime;
053    private boolean thruTimeHasBeenModified = false;
054    
055    private transient Integer _hashCode = null;
056    private transient String _stringValue = null;
057    
058    private void constructFields(OrderLinePK orderLinePK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
059            throws PersistenceNotNullException {
060        checkForNull(orderLinePK);
061        this.orderLinePK = orderLinePK;
062        checkForNull(offerUsePK);
063        this.offerUsePK = offerUsePK;
064        this.associateReferralPK = associateReferralPK;
065        checkForNull(fromTime);
066        this.fromTime = fromTime;
067        checkForNull(thruTime);
068        this.thruTime = thruTime;
069    }
070    
071    /** Creates a new instance of SalesOrderLineValue */
072    public SalesOrderLineValue(SalesOrderLinePK salesOrderLinePK, OrderLinePK orderLinePK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
073            throws PersistenceNotNullException {
074        super(salesOrderLinePK);
075        constructFields(orderLinePK, offerUsePK, associateReferralPK, fromTime, thruTime);
076    }
077    
078    /** Creates a new instance of SalesOrderLineValue */
079    public SalesOrderLineValue(OrderLinePK orderLinePK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
080            throws PersistenceNotNullException {
081        super();
082        constructFields(orderLinePK, offerUsePK, associateReferralPK, fromTime, thruTime);
083    }
084    
085   @Override
086   public SalesOrderLineFactory getBaseFactoryInstance() {
087        return SalesOrderLineFactory.getInstance();
088    }
089    
090    @Override
091    public SalesOrderLineValue clone() {
092        Object result;
093        
094        try {
095            result = super.clone();
096        } catch (CloneNotSupportedException cnse) {
097            // This shouldn't happen, fail when it does.
098            throw new PersistenceCloneException(cnse);
099        }
100        
101        return (SalesOrderLineValue)result;
102    }
103    
104   @Override
105    public SalesOrderLinePK getPrimaryKey() {
106        if(_primaryKey == null) {
107            _primaryKey = new SalesOrderLinePK(entityId);
108        }
109        
110        return _primaryKey;
111    }
112    
113    private void clearHashAndString() {
114        _hashCode = null;
115        _stringValue = null;
116    }
117    
118    @Override
119    public int hashCode() {
120        if(_hashCode == null) {
121            int hashCode = 17;
122            
123            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
124            
125            hashCode = 37 * hashCode + ((orderLinePK != null) ? orderLinePK.hashCode() : 0);
126            hashCode = 37 * hashCode + ((offerUsePK != null) ? offerUsePK.hashCode() : 0);
127            hashCode = 37 * hashCode + ((associateReferralPK != null) ? associateReferralPK.hashCode() : 0);
128            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
129            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
130            
131            _hashCode = hashCode;
132        }
133        
134        return _hashCode;
135    }
136    
137    @Override
138    public String toString() {
139        if(_stringValue == null) {
140            _stringValue = "{" + 
141                    "entityId=" + getEntityId() +
142                    ", orderLinePK=" + getOrderLinePK() +
143                    ", offerUsePK=" + getOfferUsePK() +
144                    ", associateReferralPK=" + getAssociateReferralPK() +
145                    ", fromTime=" + getFromTime() +
146                    ", thruTime=" + getThruTime() +
147                    "}";
148        }
149        return _stringValue;
150    }
151    
152    @Override
153    public boolean equals(Object other) {
154        if(this == other)
155            return true;
156        
157        if(!hasIdentity())
158            return false;
159        
160        if(other instanceof  SalesOrderLineValue that) {
161            if(!that.hasIdentity())
162                return false;
163            
164            Long thisEntityId = getEntityId();
165            Long thatEntityId = that.getEntityId();
166            
167            boolean objectsEqual = thisEntityId.equals(thatEntityId);
168            if(objectsEqual)
169                objectsEqual = isIdentical(that);
170            
171            return objectsEqual;
172        } else {
173            return false;
174        }
175    }
176    
177    public boolean isIdentical(Object other) {
178        if(other instanceof SalesOrderLineValue that) {
179            boolean objectsEqual = true;
180            
181            
182            if(objectsEqual) {
183                OrderLinePK thisOrderLinePK = getOrderLinePK();
184                OrderLinePK thatOrderLinePK = that.getOrderLinePK();
185                
186                if(thisOrderLinePK == null) {
187                    objectsEqual = objectsEqual && (thatOrderLinePK == null);
188                } else {
189                    objectsEqual = objectsEqual && thisOrderLinePK.equals(thatOrderLinePK);
190                }
191            }
192            
193            if(objectsEqual) {
194                OfferUsePK thisOfferUsePK = getOfferUsePK();
195                OfferUsePK thatOfferUsePK = that.getOfferUsePK();
196                
197                if(thisOfferUsePK == null) {
198                    objectsEqual = objectsEqual && (thatOfferUsePK == null);
199                } else {
200                    objectsEqual = objectsEqual && thisOfferUsePK.equals(thatOfferUsePK);
201                }
202            }
203            
204            if(objectsEqual) {
205                AssociateReferralPK thisAssociateReferralPK = getAssociateReferralPK();
206                AssociateReferralPK thatAssociateReferralPK = that.getAssociateReferralPK();
207                
208                if(thisAssociateReferralPK == null) {
209                    objectsEqual = objectsEqual && (thatAssociateReferralPK == null);
210                } else {
211                    objectsEqual = objectsEqual && thisAssociateReferralPK.equals(thatAssociateReferralPK);
212                }
213            }
214            
215            if(objectsEqual) {
216                Long thisFromTime = getFromTime();
217                Long thatFromTime = that.getFromTime();
218                
219                if(thisFromTime == null) {
220                    objectsEqual = objectsEqual && (thatFromTime == null);
221                } else {
222                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
223                }
224            }
225            
226            if(objectsEqual) {
227                Long thisThruTime = getThruTime();
228                Long thatThruTime = that.getThruTime();
229                
230                if(thisThruTime == null) {
231                    objectsEqual = objectsEqual && (thatThruTime == null);
232                } else {
233                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
234                }
235            }
236            
237            return objectsEqual;
238        } else {
239            return false;
240        }
241    }
242    
243    @Override
244    public boolean hasBeenModified() {
245        return orderLinePKHasBeenModified || offerUsePKHasBeenModified || associateReferralPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
246    }
247    
248    @Override
249    public void clearHasBeenModified() {
250        orderLinePKHasBeenModified = false;
251        offerUsePKHasBeenModified = false;
252        associateReferralPKHasBeenModified = false;
253        fromTimeHasBeenModified = false;
254        thruTimeHasBeenModified = false;
255    }
256    
257    public OrderLinePK getOrderLinePK() {
258        return orderLinePK;
259    }
260    
261    public void setOrderLinePK(OrderLinePK orderLinePK)
262            throws PersistenceNotNullException {
263        checkForNull(orderLinePK);
264        
265        boolean update = true;
266        
267        if(this.orderLinePK != null) {
268            if(this.orderLinePK.equals(orderLinePK)) {
269                update = false;
270            }
271        } else if(orderLinePK == null) {
272            update = false;
273        }
274        
275        if(update) {
276            this.orderLinePK = orderLinePK;
277            orderLinePKHasBeenModified = true;
278            clearHashAndString();
279        }
280    }
281    
282    public boolean getOrderLinePKHasBeenModified() {
283        return orderLinePKHasBeenModified;
284    }
285    
286    public OfferUsePK getOfferUsePK() {
287        return offerUsePK;
288    }
289    
290    public void setOfferUsePK(OfferUsePK offerUsePK)
291            throws PersistenceNotNullException {
292        checkForNull(offerUsePK);
293        
294        boolean update = true;
295        
296        if(this.offerUsePK != null) {
297            if(this.offerUsePK.equals(offerUsePK)) {
298                update = false;
299            }
300        } else if(offerUsePK == null) {
301            update = false;
302        }
303        
304        if(update) {
305            this.offerUsePK = offerUsePK;
306            offerUsePKHasBeenModified = true;
307            clearHashAndString();
308        }
309    }
310    
311    public boolean getOfferUsePKHasBeenModified() {
312        return offerUsePKHasBeenModified;
313    }
314    
315    public AssociateReferralPK getAssociateReferralPK() {
316        return associateReferralPK;
317    }
318    
319    public void setAssociateReferralPK(AssociateReferralPK associateReferralPK) {
320        boolean update = true;
321        
322        if(this.associateReferralPK != null) {
323            if(this.associateReferralPK.equals(associateReferralPK)) {
324                update = false;
325            }
326        } else if(associateReferralPK == null) {
327            update = false;
328        }
329        
330        if(update) {
331            this.associateReferralPK = associateReferralPK;
332            associateReferralPKHasBeenModified = true;
333            clearHashAndString();
334        }
335    }
336    
337    public boolean getAssociateReferralPKHasBeenModified() {
338        return associateReferralPKHasBeenModified;
339    }
340    
341    public Long getFromTime() {
342        return fromTime;
343    }
344    
345    public void setFromTime(Long fromTime)
346            throws PersistenceNotNullException {
347        checkForNull(fromTime);
348        
349        boolean update = true;
350        
351        if(this.fromTime != null) {
352            if(this.fromTime.equals(fromTime)) {
353                update = false;
354            }
355        } else if(fromTime == null) {
356            update = false;
357        }
358        
359        if(update) {
360            this.fromTime = fromTime;
361            fromTimeHasBeenModified = true;
362            clearHashAndString();
363        }
364    }
365    
366    public boolean getFromTimeHasBeenModified() {
367        return fromTimeHasBeenModified;
368    }
369    
370    public Long getThruTime() {
371        return thruTime;
372    }
373    
374    public void setThruTime(Long thruTime)
375            throws PersistenceNotNullException {
376        checkForNull(thruTime);
377        
378        boolean update = true;
379        
380        if(this.thruTime != null) {
381            if(this.thruTime.equals(thruTime)) {
382                update = false;
383            }
384        } else if(thruTime == null) {
385            update = false;
386        }
387        
388        if(update) {
389            this.thruTime = thruTime;
390            thruTimeHasBeenModified = true;
391            clearHashAndString();
392        }
393    }
394    
395    public boolean getThruTimeHasBeenModified() {
396        return thruTimeHasBeenModified;
397    }
398    
399}