001// --------------------------------------------------------------------------------
002// Copyright 2002-2026 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
040import javax.annotation.Nonnull;
041import javax.annotation.Nullable;
042
043public class SalesOrderValue
044        extends BaseValue<SalesOrderPK>
045        implements Cloneable, Serializable {
046    
047    private OrderPK orderPK;
048    private boolean orderPKHasBeenModified = false;
049    private OfferUsePK offerUsePK;
050    private boolean offerUsePKHasBeenModified = false;
051    private AssociateReferralPK associateReferralPK;
052    private boolean associateReferralPKHasBeenModified = false;
053    private Long fromTime;
054    private boolean fromTimeHasBeenModified = false;
055    private Long thruTime;
056    private boolean thruTimeHasBeenModified = false;
057    
058    private transient Integer _hashCode = null;
059    private transient String _stringValue = null;
060    
061    private void constructFields(OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(orderPK);
064        this.orderPK = orderPK;
065        checkForNull(offerUsePK);
066        this.offerUsePK = offerUsePK;
067        this.associateReferralPK = associateReferralPK;
068        checkForNull(fromTime);
069        this.fromTime = fromTime;
070        checkForNull(thruTime);
071        this.thruTime = thruTime;
072    }
073    
074    /** Creates a new instance of SalesOrderValue */
075    public SalesOrderValue(SalesOrderPK salesOrderPK, OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super(salesOrderPK);
078        constructFields(orderPK, offerUsePK, associateReferralPK, fromTime, thruTime);
079    }
080    
081    /** Creates a new instance of SalesOrderValue */
082    public SalesOrderValue(OrderPK orderPK, OfferUsePK offerUsePK, AssociateReferralPK associateReferralPK, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super();
085        constructFields(orderPK, offerUsePK, associateReferralPK, fromTime, thruTime);
086    }
087    
088    @Override
089    @Nonnull
090    public SalesOrderFactory getBaseFactoryInstance() {
091        return SalesOrderFactory.getInstance();
092    }
093    
094    @Override
095    @Nonnull
096    public SalesOrderValue clone() {
097        Object result;
098        
099        try {
100            result = super.clone();
101        } catch (CloneNotSupportedException cnse) {
102            // This shouldn't happen, fail when it does.
103            throw new PersistenceCloneException(cnse);
104        }
105        
106        return (SalesOrderValue)result;
107    }
108    
109    @Override
110    @Nonnull
111    public SalesOrderPK getPrimaryKey() {
112        if(_primaryKey == null) {
113            _primaryKey = new SalesOrderPK(entityId);
114        }
115        
116        return _primaryKey;
117    }
118    
119    private void clearHashAndString() {
120        _hashCode = null;
121        _stringValue = null;
122    }
123    
124    @Override
125    public int hashCode() {
126        if(_hashCode == null) {
127            int hashCode = 17;
128            
129            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
130            
131            hashCode = 37 * hashCode + ((orderPK != null) ? orderPK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((offerUsePK != null) ? offerUsePK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((associateReferralPK != null) ? associateReferralPK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
135            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
136            
137            _hashCode = hashCode;
138        }
139        
140        return _hashCode;
141    }
142    
143    @Override
144    @Nonnull
145    public String toString() {
146        if(_stringValue == null) {
147            _stringValue = "{" + 
148                    "entityId=" + getEntityId() +
149                    ", orderPK=" + getOrderPK() +
150                    ", offerUsePK=" + getOfferUsePK() +
151                    ", associateReferralPK=" + getAssociateReferralPK() +
152                    ", fromTime=" + getFromTime() +
153                    ", thruTime=" + getThruTime() +
154                    "}";
155        }
156        return _stringValue;
157    }
158    
159    @Override
160    public boolean equals(Object other) {
161        if(this == other)
162            return true;
163        
164        if(!hasIdentity())
165            return false;
166        
167        if(other instanceof  SalesOrderValue that) {
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 = 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 that) {
186            boolean objectsEqual = true;
187            
188            
189            if(objectsEqual) {
190                OrderPK thisOrderPK = getOrderPK();
191                OrderPK thatOrderPK = that.getOrderPK();
192                
193                if(thisOrderPK == null) {
194                    objectsEqual = objectsEqual && (thatOrderPK == null);
195                } else {
196                    objectsEqual = objectsEqual && thisOrderPK.equals(thatOrderPK);
197                }
198            }
199            
200            if(objectsEqual) {
201                OfferUsePK thisOfferUsePK = getOfferUsePK();
202                OfferUsePK thatOfferUsePK = that.getOfferUsePK();
203                
204                if(thisOfferUsePK == null) {
205                    objectsEqual = objectsEqual && (thatOfferUsePK == null);
206                } else {
207                    objectsEqual = objectsEqual && thisOfferUsePK.equals(thatOfferUsePK);
208                }
209            }
210            
211            if(objectsEqual) {
212                AssociateReferralPK thisAssociateReferralPK = getAssociateReferralPK();
213                AssociateReferralPK thatAssociateReferralPK = that.getAssociateReferralPK();
214                
215                if(thisAssociateReferralPK == null) {
216                    objectsEqual = objectsEqual && (thatAssociateReferralPK == null);
217                } else {
218                    objectsEqual = objectsEqual && thisAssociateReferralPK.equals(thatAssociateReferralPK);
219                }
220            }
221            
222            if(objectsEqual) {
223                Long thisFromTime = getFromTime();
224                Long thatFromTime = that.getFromTime();
225                
226                if(thisFromTime == null) {
227                    objectsEqual = objectsEqual && (thatFromTime == null);
228                } else {
229                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
230                }
231            }
232            
233            if(objectsEqual) {
234                Long thisThruTime = getThruTime();
235                Long thatThruTime = that.getThruTime();
236                
237                if(thisThruTime == null) {
238                    objectsEqual = objectsEqual && (thatThruTime == null);
239                } else {
240                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
241                }
242            }
243            
244            return objectsEqual;
245        } else {
246            return false;
247        }
248    }
249    
250    @Override
251    public boolean hasBeenModified() {
252        return orderPKHasBeenModified || offerUsePKHasBeenModified || associateReferralPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
253    }
254    
255    @Override
256    public void clearHasBeenModified() {
257        orderPKHasBeenModified = false;
258        offerUsePKHasBeenModified = false;
259        associateReferralPKHasBeenModified = false;
260        fromTimeHasBeenModified = false;
261        thruTimeHasBeenModified = false;
262    }
263    
264    @Nonnull
265    public OrderPK getOrderPK() {
266        return orderPK;
267    }
268    
269    public void setOrderPK(@Nonnull 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    @Nonnull
295    public OfferUsePK getOfferUsePK() {
296        return offerUsePK;
297    }
298    
299    public void setOfferUsePK(@Nonnull OfferUsePK offerUsePK)
300            throws PersistenceNotNullException {
301        checkForNull(offerUsePK);
302        
303        boolean update = true;
304        
305        if(this.offerUsePK != null) {
306            if(this.offerUsePK.equals(offerUsePK)) {
307                update = false;
308            }
309        } else if(offerUsePK == null) {
310            update = false;
311        }
312        
313        if(update) {
314            this.offerUsePK = offerUsePK;
315            offerUsePKHasBeenModified = true;
316            clearHashAndString();
317        }
318    }
319    
320    public boolean getOfferUsePKHasBeenModified() {
321        return offerUsePKHasBeenModified;
322    }
323    
324    @Nullable
325    public AssociateReferralPK getAssociateReferralPK() {
326        return associateReferralPK;
327    }
328    
329    public void setAssociateReferralPK(@Nullable AssociateReferralPK associateReferralPK) {
330        boolean update = true;
331        
332        if(this.associateReferralPK != null) {
333            if(this.associateReferralPK.equals(associateReferralPK)) {
334                update = false;
335            }
336        } else if(associateReferralPK == null) {
337            update = false;
338        }
339        
340        if(update) {
341            this.associateReferralPK = associateReferralPK;
342            associateReferralPKHasBeenModified = true;
343            clearHashAndString();
344        }
345    }
346    
347    public boolean getAssociateReferralPKHasBeenModified() {
348        return associateReferralPKHasBeenModified;
349    }
350    
351    @Nonnull
352    public Long getFromTime() {
353        return fromTime;
354    }
355    
356    public void setFromTime(@Nonnull Long fromTime)
357            throws PersistenceNotNullException {
358        checkForNull(fromTime);
359        
360        boolean update = true;
361        
362        if(this.fromTime != null) {
363            if(this.fromTime.equals(fromTime)) {
364                update = false;
365            }
366        } else if(fromTime == null) {
367            update = false;
368        }
369        
370        if(update) {
371            this.fromTime = fromTime;
372            fromTimeHasBeenModified = true;
373            clearHashAndString();
374        }
375    }
376    
377    public boolean getFromTimeHasBeenModified() {
378        return fromTimeHasBeenModified;
379    }
380    
381    @Nonnull
382    public Long getThruTime() {
383        return thruTime;
384    }
385    
386    public void setThruTime(@Nonnull Long thruTime)
387            throws PersistenceNotNullException {
388        checkForNull(thruTime);
389        
390        boolean update = true;
391        
392        if(this.thruTime != null) {
393            if(this.thruTime.equals(thruTime)) {
394                update = false;
395            }
396        } else if(thruTime == null) {
397            update = false;
398        }
399        
400        if(update) {
401            this.thruTime = thruTime;
402            thruTimeHasBeenModified = true;
403            clearHashAndString();
404        }
405    }
406    
407    public boolean getThruTimeHasBeenModified() {
408        return thruTimeHasBeenModified;
409    }
410    
411}