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 * SalesOrderValue.java
021 */
022
023package com.echothree.model.data.sales.server.value;
024
025import com.echothree.model.data.sales.common.pk.SalesOrderPK;
026
027import com.echothree.model.data.sales.server.factory.SalesOrderFactory;
028
029import com.echothree.model.data.order.common.pk.OrderPK;
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 SalesOrderValue
041        extends BaseValue<SalesOrderPK>
042        implements Cloneable, Serializable {
043    
044    private OrderPK orderPK;
045    private boolean orderPKHasBeenModified = 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(OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
059            throws PersistenceNotNullException {
060        checkForNull(orderPK);
061        this.orderPK = orderPK;
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 SalesOrderValue */
072    public SalesOrderValue(SalesOrderPK salesOrderPK, OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
073            throws PersistenceNotNullException {
074        super(salesOrderPK);
075        constructFields(orderPK, offerUsePK, associateReferralPK, fromTime, thruTime);
076    }
077    
078    /** Creates a new instance of SalesOrderValue */
079    public SalesOrderValue(OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
080            throws PersistenceNotNullException {
081        super();
082        constructFields(orderPK, offerUsePK, associateReferralPK, fromTime, thruTime);
083    }
084    
085   @Override
086   public SalesOrderFactory getBaseFactoryInstance() {
087        return SalesOrderFactory.getInstance();
088    }
089    
090    @Override
091    public SalesOrderValue 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 (SalesOrderValue)result;
102    }
103    
104   @Override
105    public SalesOrderPK getPrimaryKey() {
106        if(_primaryKey == null) {
107            _primaryKey = new SalesOrderPK(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 + ((orderPK != null) ? orderPK.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            StringBuilder stringValue = new StringBuilder("{");
141            
142            stringValue.append("entityId=").append(getEntityId());
143            
144            stringValue.append(", orderPK=").append(getOrderPK());
145            stringValue.append(", offerUsePK=").append(getOfferUsePK());
146            stringValue.append(", associateReferralPK=").append(getAssociateReferralPK());
147            stringValue.append(", fromTime=").append(getFromTime());
148            stringValue.append(", thruTime=").append(getThruTime());
149            
150            stringValue.append('}');
151            
152            _stringValue = stringValue.toString();
153        }
154        return _stringValue;
155    }
156    
157    @Override
158    public boolean equals(Object other) {
159        if(this == other)
160            return true;
161        
162        if(!hasIdentity())
163            return false;
164        
165        if(other instanceof  SalesOrderValue) {
166            SalesOrderValue that = (SalesOrderValue)other;
167            
168            if(!that.hasIdentity())
169                return false;
170            
171            Long thisEntityId = getEntityId();
172            Long thatEntityId = that.getEntityId();
173            
174            boolean objectsEqual = thisEntityId.equals(thatEntityId);
175            if(objectsEqual)
176                objectsEqual = objectsEqual && isIdentical(that);
177            
178            return objectsEqual;
179        } else {
180            return false;
181        }
182    }
183    
184    public boolean isIdentical(Object other) {
185        if(other instanceof SalesOrderValue) {
186            SalesOrderValue that = (SalesOrderValue)other;
187            boolean objectsEqual = true;
188            
189            
190            if(objectsEqual) {
191                OrderPK thisOrderPK = getOrderPK();
192                OrderPK thatOrderPK = that.getOrderPK();
193                
194                if(thisOrderPK == null) {
195                    objectsEqual = objectsEqual && (thatOrderPK == null);
196                } else {
197                    objectsEqual = objectsEqual && thisOrderPK.equals(thatOrderPK);
198                }
199            }
200            
201            if(objectsEqual) {
202                OfferUsePK thisOfferUsePK = getOfferUsePK();
203                OfferUsePK thatOfferUsePK = that.getOfferUsePK();
204                
205                if(thisOfferUsePK == null) {
206                    objectsEqual = objectsEqual && (thatOfferUsePK == null);
207                } else {
208                    objectsEqual = objectsEqual && thisOfferUsePK.equals(thatOfferUsePK);
209                }
210            }
211            
212            if(objectsEqual) {
213                AssociateReferralPK thisAssociateReferralPK = getAssociateReferralPK();
214                AssociateReferralPK thatAssociateReferralPK = that.getAssociateReferralPK();
215                
216                if(thisAssociateReferralPK == null) {
217                    objectsEqual = objectsEqual && (thatAssociateReferralPK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisAssociateReferralPK.equals(thatAssociateReferralPK);
220                }
221            }
222            
223            if(objectsEqual) {
224                Long thisFromTime = getFromTime();
225                Long thatFromTime = that.getFromTime();
226                
227                if(thisFromTime == null) {
228                    objectsEqual = objectsEqual && (thatFromTime == null);
229                } else {
230                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
231                }
232            }
233            
234            if(objectsEqual) {
235                Long thisThruTime = getThruTime();
236                Long thatThruTime = that.getThruTime();
237                
238                if(thisThruTime == null) {
239                    objectsEqual = objectsEqual && (thatThruTime == null);
240                } else {
241                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
242                }
243            }
244            
245            return objectsEqual;
246        } else {
247            return false;
248        }
249    }
250    
251    @Override
252    public boolean hasBeenModified() {
253        return orderPKHasBeenModified || offerUsePKHasBeenModified || associateReferralPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
254    }
255    
256    @Override
257    public void clearHasBeenModified() {
258        orderPKHasBeenModified = false;
259        offerUsePKHasBeenModified = false;
260        associateReferralPKHasBeenModified = false;
261        fromTimeHasBeenModified = false;
262        thruTimeHasBeenModified = false;
263    }
264    
265    public OrderPK getOrderPK() {
266        return orderPK;
267    }
268    
269    public void setOrderPK(OrderPK orderPK)
270            throws PersistenceNotNullException {
271        checkForNull(orderPK);
272        
273        boolean update = true;
274        
275        if(this.orderPK != null) {
276            if(this.orderPK.equals(orderPK)) {
277                update = false;
278            }
279        } else if(orderPK == null) {
280            update = false;
281        }
282        
283        if(update) {
284            this.orderPK = orderPK;
285            orderPKHasBeenModified = true;
286            clearHashAndString();
287        }
288    }
289    
290    public boolean getOrderPKHasBeenModified() {
291        return orderPKHasBeenModified;
292    }
293    
294    public OfferUsePK getOfferUsePK() {
295        return offerUsePK;
296    }
297    
298    public void setOfferUsePK(OfferUsePK offerUsePK)
299            throws PersistenceNotNullException {
300        checkForNull(offerUsePK);
301        
302        boolean update = true;
303        
304        if(this.offerUsePK != null) {
305            if(this.offerUsePK.equals(offerUsePK)) {
306                update = false;
307            }
308        } else if(offerUsePK == null) {
309            update = false;
310        }
311        
312        if(update) {
313            this.offerUsePK = offerUsePK;
314            offerUsePKHasBeenModified = true;
315            clearHashAndString();
316        }
317    }
318    
319    public boolean getOfferUsePKHasBeenModified() {
320        return offerUsePKHasBeenModified;
321    }
322    
323    public AssociateReferralPK getAssociateReferralPK() {
324        return associateReferralPK;
325    }
326    
327    public void setAssociateReferralPK(AssociateReferralPK associateReferralPK) {
328        boolean update = true;
329        
330        if(this.associateReferralPK != null) {
331            if(this.associateReferralPK.equals(associateReferralPK)) {
332                update = false;
333            }
334        } else if(associateReferralPK == null) {
335            update = false;
336        }
337        
338        if(update) {
339            this.associateReferralPK = associateReferralPK;
340            associateReferralPKHasBeenModified = true;
341            clearHashAndString();
342        }
343    }
344    
345    public boolean getAssociateReferralPKHasBeenModified() {
346        return associateReferralPKHasBeenModified;
347    }
348    
349    public Long getFromTime() {
350        return fromTime;
351    }
352    
353    public void setFromTime(Long fromTime)
354            throws PersistenceNotNullException {
355        checkForNull(fromTime);
356        
357        boolean update = true;
358        
359        if(this.fromTime != null) {
360            if(this.fromTime.equals(fromTime)) {
361                update = false;
362            }
363        } else if(fromTime == null) {
364            update = false;
365        }
366        
367        if(update) {
368            this.fromTime = fromTime;
369            fromTimeHasBeenModified = true;
370            clearHashAndString();
371        }
372    }
373    
374    public boolean getFromTimeHasBeenModified() {
375        return fromTimeHasBeenModified;
376    }
377    
378    public Long getThruTime() {
379        return thruTime;
380    }
381    
382    public void setThruTime(Long thruTime)
383            throws PersistenceNotNullException {
384        checkForNull(thruTime);
385        
386        boolean update = true;
387        
388        if(this.thruTime != null) {
389            if(this.thruTime.equals(thruTime)) {
390                update = false;
391            }
392        } else if(thruTime == null) {
393            update = false;
394        }
395        
396        if(update) {
397            this.thruTime = thruTime;
398            thruTimeHasBeenModified = true;
399            clearHashAndString();
400        }
401    }
402    
403    public boolean getThruTimeHasBeenModified() {
404        return thruTimeHasBeenModified;
405    }
406    
407}