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 * OfferDetailValue.java
021 */
022
023package com.echothree.model.data.offer.server.value;
024
025import com.echothree.model.data.offer.common.pk.OfferDetailPK;
026
027import com.echothree.model.data.offer.server.factory.OfferDetailFactory;
028
029import com.echothree.model.data.offer.common.pk.OfferPK;
030import com.echothree.model.data.sequence.common.pk.SequencePK;
031import com.echothree.model.data.party.common.pk.PartyPK;
032import com.echothree.model.data.selector.common.pk.SelectorPK;
033import com.echothree.model.data.filter.common.pk.FilterPK;
034
035import com.echothree.util.common.exception.PersistenceCloneException;
036import com.echothree.util.common.exception.PersistenceNotNullException;
037
038import com.echothree.util.server.persistence.BaseValue;
039
040import java.io.Serializable;
041
042public class OfferDetailValue
043        extends BaseValue<OfferDetailPK>
044        implements Cloneable, Serializable {
045    
046    private OfferPK offerPK;
047    private boolean offerPKHasBeenModified = false;
048    private String offerName;
049    private boolean offerNameHasBeenModified = false;
050    private SequencePK salesOrderSequencePK;
051    private boolean salesOrderSequencePKHasBeenModified = false;
052    private PartyPK departmentPartyPK;
053    private boolean departmentPartyPKHasBeenModified = false;
054    private SelectorPK offerItemSelectorPK;
055    private boolean offerItemSelectorPKHasBeenModified = false;
056    private FilterPK offerItemPriceFilterPK;
057    private boolean offerItemPriceFilterPKHasBeenModified = false;
058    private Boolean isDefault;
059    private boolean isDefaultHasBeenModified = false;
060    private Integer sortOrder;
061    private boolean sortOrderHasBeenModified = false;
062    private Long fromTime;
063    private boolean fromTimeHasBeenModified = false;
064    private Long thruTime;
065    private boolean thruTimeHasBeenModified = false;
066    
067    private transient Integer _hashCode = null;
068    private transient String _stringValue = null;
069    
070    private void constructFields(OfferPK offerPK, String offerName, SequencePK salesOrderSequencePK, PartyPK departmentPartyPK, SelectorPK offerItemSelectorPK, FilterPK offerItemPriceFilterPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
071            throws PersistenceNotNullException {
072        checkForNull(offerPK);
073        this.offerPK = offerPK;
074        checkForNull(offerName);
075        this.offerName = offerName;
076        this.salesOrderSequencePK = salesOrderSequencePK;
077        checkForNull(departmentPartyPK);
078        this.departmentPartyPK = departmentPartyPK;
079        this.offerItemSelectorPK = offerItemSelectorPK;
080        this.offerItemPriceFilterPK = offerItemPriceFilterPK;
081        checkForNull(isDefault);
082        this.isDefault = isDefault;
083        checkForNull(sortOrder);
084        this.sortOrder = sortOrder;
085        checkForNull(fromTime);
086        this.fromTime = fromTime;
087        checkForNull(thruTime);
088        this.thruTime = thruTime;
089    }
090    
091    /** Creates a new instance of OfferDetailValue */
092    public OfferDetailValue(OfferDetailPK offerDetailPK, OfferPK offerPK, String offerName, SequencePK salesOrderSequencePK, PartyPK departmentPartyPK, SelectorPK offerItemSelectorPK, FilterPK offerItemPriceFilterPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
093            throws PersistenceNotNullException {
094        super(offerDetailPK);
095        constructFields(offerPK, offerName, salesOrderSequencePK, departmentPartyPK, offerItemSelectorPK, offerItemPriceFilterPK, isDefault, sortOrder, fromTime, thruTime);
096    }
097    
098    /** Creates a new instance of OfferDetailValue */
099    public OfferDetailValue(OfferPK offerPK, String offerName, SequencePK salesOrderSequencePK, PartyPK departmentPartyPK, SelectorPK offerItemSelectorPK, FilterPK offerItemPriceFilterPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
100            throws PersistenceNotNullException {
101        super();
102        constructFields(offerPK, offerName, salesOrderSequencePK, departmentPartyPK, offerItemSelectorPK, offerItemPriceFilterPK, isDefault, sortOrder, fromTime, thruTime);
103    }
104    
105   @Override
106   public OfferDetailFactory getBaseFactoryInstance() {
107        return OfferDetailFactory.getInstance();
108    }
109    
110    @Override
111    public OfferDetailValue clone() {
112        Object result;
113        
114        try {
115            result = super.clone();
116        } catch (CloneNotSupportedException cnse) {
117            // This shouldn't happen, fail when it does.
118            throw new PersistenceCloneException(cnse);
119        }
120        
121        return (OfferDetailValue)result;
122    }
123    
124   @Override
125    public OfferDetailPK getPrimaryKey() {
126        if(_primaryKey == null) {
127            _primaryKey = new OfferDetailPK(entityId);
128        }
129        
130        return _primaryKey;
131    }
132    
133    private void clearHashAndString() {
134        _hashCode = null;
135        _stringValue = null;
136    }
137    
138    @Override
139    public int hashCode() {
140        if(_hashCode == null) {
141            int hashCode = 17;
142            
143            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
144            
145            hashCode = 37 * hashCode + ((offerPK != null) ? offerPK.hashCode() : 0);
146            hashCode = 37 * hashCode + ((offerName != null) ? offerName.hashCode() : 0);
147            hashCode = 37 * hashCode + ((salesOrderSequencePK != null) ? salesOrderSequencePK.hashCode() : 0);
148            hashCode = 37 * hashCode + ((departmentPartyPK != null) ? departmentPartyPK.hashCode() : 0);
149            hashCode = 37 * hashCode + ((offerItemSelectorPK != null) ? offerItemSelectorPK.hashCode() : 0);
150            hashCode = 37 * hashCode + ((offerItemPriceFilterPK != null) ? offerItemPriceFilterPK.hashCode() : 0);
151            hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0);
152            hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0);
153            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
154            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
155            
156            _hashCode = hashCode;
157        }
158        
159        return _hashCode;
160    }
161    
162    @Override
163    public String toString() {
164        if(_stringValue == null) {
165            StringBuilder stringValue = new StringBuilder("{");
166            
167            stringValue.append("entityId=").append(getEntityId());
168            
169            stringValue.append(", offerPK=").append(getOfferPK());
170            stringValue.append(", offerName=").append(getOfferName());
171            stringValue.append(", salesOrderSequencePK=").append(getSalesOrderSequencePK());
172            stringValue.append(", departmentPartyPK=").append(getDepartmentPartyPK());
173            stringValue.append(", offerItemSelectorPK=").append(getOfferItemSelectorPK());
174            stringValue.append(", offerItemPriceFilterPK=").append(getOfferItemPriceFilterPK());
175            stringValue.append(", isDefault=").append(getIsDefault());
176            stringValue.append(", sortOrder=").append(getSortOrder());
177            stringValue.append(", fromTime=").append(getFromTime());
178            stringValue.append(", thruTime=").append(getThruTime());
179            
180            stringValue.append('}');
181            
182            _stringValue = stringValue.toString();
183        }
184        return _stringValue;
185    }
186    
187    @Override
188    public boolean equals(Object other) {
189        if(this == other)
190            return true;
191        
192        if(!hasIdentity())
193            return false;
194        
195        if(other instanceof  OfferDetailValue) {
196            OfferDetailValue that = (OfferDetailValue)other;
197            
198            if(!that.hasIdentity())
199                return false;
200            
201            Long thisEntityId = getEntityId();
202            Long thatEntityId = that.getEntityId();
203            
204            boolean objectsEqual = thisEntityId.equals(thatEntityId);
205            if(objectsEqual)
206                objectsEqual = objectsEqual && isIdentical(that);
207            
208            return objectsEqual;
209        } else {
210            return false;
211        }
212    }
213    
214    public boolean isIdentical(Object other) {
215        if(other instanceof OfferDetailValue) {
216            OfferDetailValue that = (OfferDetailValue)other;
217            boolean objectsEqual = true;
218            
219            
220            if(objectsEqual) {
221                OfferPK thisOfferPK = getOfferPK();
222                OfferPK thatOfferPK = that.getOfferPK();
223                
224                if(thisOfferPK == null) {
225                    objectsEqual = objectsEqual && (thatOfferPK == null);
226                } else {
227                    objectsEqual = objectsEqual && thisOfferPK.equals(thatOfferPK);
228                }
229            }
230            
231            if(objectsEqual) {
232                String thisOfferName = getOfferName();
233                String thatOfferName = that.getOfferName();
234                
235                if(thisOfferName == null) {
236                    objectsEqual = objectsEqual && (thatOfferName == null);
237                } else {
238                    objectsEqual = objectsEqual && thisOfferName.equals(thatOfferName);
239                }
240            }
241            
242            if(objectsEqual) {
243                SequencePK thisSalesOrderSequencePK = getSalesOrderSequencePK();
244                SequencePK thatSalesOrderSequencePK = that.getSalesOrderSequencePK();
245                
246                if(thisSalesOrderSequencePK == null) {
247                    objectsEqual = objectsEqual && (thatSalesOrderSequencePK == null);
248                } else {
249                    objectsEqual = objectsEqual && thisSalesOrderSequencePK.equals(thatSalesOrderSequencePK);
250                }
251            }
252            
253            if(objectsEqual) {
254                PartyPK thisDepartmentPartyPK = getDepartmentPartyPK();
255                PartyPK thatDepartmentPartyPK = that.getDepartmentPartyPK();
256                
257                if(thisDepartmentPartyPK == null) {
258                    objectsEqual = objectsEqual && (thatDepartmentPartyPK == null);
259                } else {
260                    objectsEqual = objectsEqual && thisDepartmentPartyPK.equals(thatDepartmentPartyPK);
261                }
262            }
263            
264            if(objectsEqual) {
265                SelectorPK thisOfferItemSelectorPK = getOfferItemSelectorPK();
266                SelectorPK thatOfferItemSelectorPK = that.getOfferItemSelectorPK();
267                
268                if(thisOfferItemSelectorPK == null) {
269                    objectsEqual = objectsEqual && (thatOfferItemSelectorPK == null);
270                } else {
271                    objectsEqual = objectsEqual && thisOfferItemSelectorPK.equals(thatOfferItemSelectorPK);
272                }
273            }
274            
275            if(objectsEqual) {
276                FilterPK thisOfferItemPriceFilterPK = getOfferItemPriceFilterPK();
277                FilterPK thatOfferItemPriceFilterPK = that.getOfferItemPriceFilterPK();
278                
279                if(thisOfferItemPriceFilterPK == null) {
280                    objectsEqual = objectsEqual && (thatOfferItemPriceFilterPK == null);
281                } else {
282                    objectsEqual = objectsEqual && thisOfferItemPriceFilterPK.equals(thatOfferItemPriceFilterPK);
283                }
284            }
285            
286            if(objectsEqual) {
287                Boolean thisIsDefault = getIsDefault();
288                Boolean thatIsDefault = that.getIsDefault();
289                
290                if(thisIsDefault == null) {
291                    objectsEqual = objectsEqual && (thatIsDefault == null);
292                } else {
293                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
294                }
295            }
296            
297            if(objectsEqual) {
298                Integer thisSortOrder = getSortOrder();
299                Integer thatSortOrder = that.getSortOrder();
300                
301                if(thisSortOrder == null) {
302                    objectsEqual = objectsEqual && (thatSortOrder == null);
303                } else {
304                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
305                }
306            }
307            
308            if(objectsEqual) {
309                Long thisFromTime = getFromTime();
310                Long thatFromTime = that.getFromTime();
311                
312                if(thisFromTime == null) {
313                    objectsEqual = objectsEqual && (thatFromTime == null);
314                } else {
315                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
316                }
317            }
318            
319            if(objectsEqual) {
320                Long thisThruTime = getThruTime();
321                Long thatThruTime = that.getThruTime();
322                
323                if(thisThruTime == null) {
324                    objectsEqual = objectsEqual && (thatThruTime == null);
325                } else {
326                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
327                }
328            }
329            
330            return objectsEqual;
331        } else {
332            return false;
333        }
334    }
335    
336    @Override
337    public boolean hasBeenModified() {
338        return offerPKHasBeenModified || offerNameHasBeenModified || salesOrderSequencePKHasBeenModified || departmentPartyPKHasBeenModified || offerItemSelectorPKHasBeenModified || offerItemPriceFilterPKHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
339    }
340    
341    @Override
342    public void clearHasBeenModified() {
343        offerPKHasBeenModified = false;
344        offerNameHasBeenModified = false;
345        salesOrderSequencePKHasBeenModified = false;
346        departmentPartyPKHasBeenModified = false;
347        offerItemSelectorPKHasBeenModified = false;
348        offerItemPriceFilterPKHasBeenModified = false;
349        isDefaultHasBeenModified = false;
350        sortOrderHasBeenModified = false;
351        fromTimeHasBeenModified = false;
352        thruTimeHasBeenModified = false;
353    }
354    
355    public OfferPK getOfferPK() {
356        return offerPK;
357    }
358    
359    public void setOfferPK(OfferPK offerPK)
360            throws PersistenceNotNullException {
361        checkForNull(offerPK);
362        
363        boolean update = true;
364        
365        if(this.offerPK != null) {
366            if(this.offerPK.equals(offerPK)) {
367                update = false;
368            }
369        } else if(offerPK == null) {
370            update = false;
371        }
372        
373        if(update) {
374            this.offerPK = offerPK;
375            offerPKHasBeenModified = true;
376            clearHashAndString();
377        }
378    }
379    
380    public boolean getOfferPKHasBeenModified() {
381        return offerPKHasBeenModified;
382    }
383    
384    public String getOfferName() {
385        return offerName;
386    }
387    
388    public void setOfferName(String offerName)
389            throws PersistenceNotNullException {
390        checkForNull(offerName);
391        
392        boolean update = true;
393        
394        if(this.offerName != null) {
395            if(this.offerName.equals(offerName)) {
396                update = false;
397            }
398        } else if(offerName == null) {
399            update = false;
400        }
401        
402        if(update) {
403            this.offerName = offerName;
404            offerNameHasBeenModified = true;
405            clearHashAndString();
406        }
407    }
408    
409    public boolean getOfferNameHasBeenModified() {
410        return offerNameHasBeenModified;
411    }
412    
413    public SequencePK getSalesOrderSequencePK() {
414        return salesOrderSequencePK;
415    }
416    
417    public void setSalesOrderSequencePK(SequencePK salesOrderSequencePK) {
418        boolean update = true;
419        
420        if(this.salesOrderSequencePK != null) {
421            if(this.salesOrderSequencePK.equals(salesOrderSequencePK)) {
422                update = false;
423            }
424        } else if(salesOrderSequencePK == null) {
425            update = false;
426        }
427        
428        if(update) {
429            this.salesOrderSequencePK = salesOrderSequencePK;
430            salesOrderSequencePKHasBeenModified = true;
431            clearHashAndString();
432        }
433    }
434    
435    public boolean getSalesOrderSequencePKHasBeenModified() {
436        return salesOrderSequencePKHasBeenModified;
437    }
438    
439    public PartyPK getDepartmentPartyPK() {
440        return departmentPartyPK;
441    }
442    
443    public void setDepartmentPartyPK(PartyPK departmentPartyPK)
444            throws PersistenceNotNullException {
445        checkForNull(departmentPartyPK);
446        
447        boolean update = true;
448        
449        if(this.departmentPartyPK != null) {
450            if(this.departmentPartyPK.equals(departmentPartyPK)) {
451                update = false;
452            }
453        } else if(departmentPartyPK == null) {
454            update = false;
455        }
456        
457        if(update) {
458            this.departmentPartyPK = departmentPartyPK;
459            departmentPartyPKHasBeenModified = true;
460            clearHashAndString();
461        }
462    }
463    
464    public boolean getDepartmentPartyPKHasBeenModified() {
465        return departmentPartyPKHasBeenModified;
466    }
467    
468    public SelectorPK getOfferItemSelectorPK() {
469        return offerItemSelectorPK;
470    }
471    
472    public void setOfferItemSelectorPK(SelectorPK offerItemSelectorPK) {
473        boolean update = true;
474        
475        if(this.offerItemSelectorPK != null) {
476            if(this.offerItemSelectorPK.equals(offerItemSelectorPK)) {
477                update = false;
478            }
479        } else if(offerItemSelectorPK == null) {
480            update = false;
481        }
482        
483        if(update) {
484            this.offerItemSelectorPK = offerItemSelectorPK;
485            offerItemSelectorPKHasBeenModified = true;
486            clearHashAndString();
487        }
488    }
489    
490    public boolean getOfferItemSelectorPKHasBeenModified() {
491        return offerItemSelectorPKHasBeenModified;
492    }
493    
494    public FilterPK getOfferItemPriceFilterPK() {
495        return offerItemPriceFilterPK;
496    }
497    
498    public void setOfferItemPriceFilterPK(FilterPK offerItemPriceFilterPK) {
499        boolean update = true;
500        
501        if(this.offerItemPriceFilterPK != null) {
502            if(this.offerItemPriceFilterPK.equals(offerItemPriceFilterPK)) {
503                update = false;
504            }
505        } else if(offerItemPriceFilterPK == null) {
506            update = false;
507        }
508        
509        if(update) {
510            this.offerItemPriceFilterPK = offerItemPriceFilterPK;
511            offerItemPriceFilterPKHasBeenModified = true;
512            clearHashAndString();
513        }
514    }
515    
516    public boolean getOfferItemPriceFilterPKHasBeenModified() {
517        return offerItemPriceFilterPKHasBeenModified;
518    }
519    
520    public Boolean getIsDefault() {
521        return isDefault;
522    }
523    
524    public void setIsDefault(Boolean isDefault)
525            throws PersistenceNotNullException {
526        checkForNull(isDefault);
527        
528        boolean update = true;
529        
530        if(this.isDefault != null) {
531            if(this.isDefault.equals(isDefault)) {
532                update = false;
533            }
534        } else if(isDefault == null) {
535            update = false;
536        }
537        
538        if(update) {
539            this.isDefault = isDefault;
540            isDefaultHasBeenModified = true;
541            clearHashAndString();
542        }
543    }
544    
545    public boolean getIsDefaultHasBeenModified() {
546        return isDefaultHasBeenModified;
547    }
548    
549    public Integer getSortOrder() {
550        return sortOrder;
551    }
552    
553    public void setSortOrder(Integer sortOrder)
554            throws PersistenceNotNullException {
555        checkForNull(sortOrder);
556        
557        boolean update = true;
558        
559        if(this.sortOrder != null) {
560            if(this.sortOrder.equals(sortOrder)) {
561                update = false;
562            }
563        } else if(sortOrder == null) {
564            update = false;
565        }
566        
567        if(update) {
568            this.sortOrder = sortOrder;
569            sortOrderHasBeenModified = true;
570            clearHashAndString();
571        }
572    }
573    
574    public boolean getSortOrderHasBeenModified() {
575        return sortOrderHasBeenModified;
576    }
577    
578    public Long getFromTime() {
579        return fromTime;
580    }
581    
582    public void setFromTime(Long fromTime)
583            throws PersistenceNotNullException {
584        checkForNull(fromTime);
585        
586        boolean update = true;
587        
588        if(this.fromTime != null) {
589            if(this.fromTime.equals(fromTime)) {
590                update = false;
591            }
592        } else if(fromTime == null) {
593            update = false;
594        }
595        
596        if(update) {
597            this.fromTime = fromTime;
598            fromTimeHasBeenModified = true;
599            clearHashAndString();
600        }
601    }
602    
603    public boolean getFromTimeHasBeenModified() {
604        return fromTimeHasBeenModified;
605    }
606    
607    public Long getThruTime() {
608        return thruTime;
609    }
610    
611    public void setThruTime(Long thruTime)
612            throws PersistenceNotNullException {
613        checkForNull(thruTime);
614        
615        boolean update = true;
616        
617        if(this.thruTime != null) {
618            if(this.thruTime.equals(thruTime)) {
619                update = false;
620            }
621        } else if(thruTime == null) {
622            update = false;
623        }
624        
625        if(update) {
626            this.thruTime = thruTime;
627            thruTimeHasBeenModified = true;
628            clearHashAndString();
629        }
630    }
631    
632    public boolean getThruTimeHasBeenModified() {
633        return thruTimeHasBeenModified;
634    }
635    
636}