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 * CampaignSourceDetailValue.java
021 */
022
023package com.echothree.model.data.campaign.server.value;
024
025import com.echothree.model.data.campaign.common.pk.CampaignSourceDetailPK;
026
027import com.echothree.model.data.campaign.server.factory.CampaignSourceDetailFactory;
028
029import com.echothree.model.data.campaign.common.pk.CampaignSourcePK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038public class CampaignSourceDetailValue
039        extends BaseValue<CampaignSourceDetailPK>
040        implements Cloneable, Serializable {
041    
042    private CampaignSourcePK campaignSourcePK;
043    private boolean campaignSourcePKHasBeenModified = false;
044    private String campaignSourceName;
045    private boolean campaignSourceNameHasBeenModified = false;
046    private String valueSha1Hash;
047    private boolean valueSha1HashHasBeenModified = false;
048    private String value;
049    private boolean valueHasBeenModified = false;
050    private Boolean isDefault;
051    private boolean isDefaultHasBeenModified = false;
052    private Integer sortOrder;
053    private boolean sortOrderHasBeenModified = 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(CampaignSourcePK campaignSourcePK, String campaignSourceName, String valueSha1Hash, String value, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
063            throws PersistenceNotNullException {
064        checkForNull(campaignSourcePK);
065        this.campaignSourcePK = campaignSourcePK;
066        checkForNull(campaignSourceName);
067        this.campaignSourceName = campaignSourceName;
068        checkForNull(valueSha1Hash);
069        this.valueSha1Hash = valueSha1Hash;
070        checkForNull(value);
071        this.value = value;
072        checkForNull(isDefault);
073        this.isDefault = isDefault;
074        checkForNull(sortOrder);
075        this.sortOrder = sortOrder;
076        checkForNull(fromTime);
077        this.fromTime = fromTime;
078        checkForNull(thruTime);
079        this.thruTime = thruTime;
080    }
081    
082    /** Creates a new instance of CampaignSourceDetailValue */
083    public CampaignSourceDetailValue(CampaignSourceDetailPK campaignSourceDetailPK, CampaignSourcePK campaignSourcePK, String campaignSourceName, String valueSha1Hash, String value, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super(campaignSourceDetailPK);
086        constructFields(campaignSourcePK, campaignSourceName, valueSha1Hash, value, isDefault, sortOrder, fromTime, thruTime);
087    }
088    
089    /** Creates a new instance of CampaignSourceDetailValue */
090    public CampaignSourceDetailValue(CampaignSourcePK campaignSourcePK, String campaignSourceName, String valueSha1Hash, String value, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
091            throws PersistenceNotNullException {
092        super();
093        constructFields(campaignSourcePK, campaignSourceName, valueSha1Hash, value, isDefault, sortOrder, fromTime, thruTime);
094    }
095    
096   @Override
097   public CampaignSourceDetailFactory getBaseFactoryInstance() {
098        return CampaignSourceDetailFactory.getInstance();
099    }
100    
101    @Override
102    public CampaignSourceDetailValue clone() {
103        Object result;
104        
105        try {
106            result = super.clone();
107        } catch (CloneNotSupportedException cnse) {
108            // This shouldn't happen, fail when it does.
109            throw new PersistenceCloneException(cnse);
110        }
111        
112        return (CampaignSourceDetailValue)result;
113    }
114    
115   @Override
116    public CampaignSourceDetailPK getPrimaryKey() {
117        if(_primaryKey == null) {
118            _primaryKey = new CampaignSourceDetailPK(entityId);
119        }
120        
121        return _primaryKey;
122    }
123    
124    private void clearHashAndString() {
125        _hashCode = null;
126        _stringValue = null;
127    }
128    
129    @Override
130    public int hashCode() {
131        if(_hashCode == null) {
132            int hashCode = 17;
133            
134            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
135            
136            hashCode = 37 * hashCode + ((campaignSourcePK != null) ? campaignSourcePK.hashCode() : 0);
137            hashCode = 37 * hashCode + ((campaignSourceName != null) ? campaignSourceName.hashCode() : 0);
138            hashCode = 37 * hashCode + ((valueSha1Hash != null) ? valueSha1Hash.hashCode() : 0);
139            hashCode = 37 * hashCode + ((value != null) ? value.hashCode() : 0);
140            hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0);
141            hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0);
142            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
143            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
144            
145            _hashCode = hashCode;
146        }
147        
148        return _hashCode;
149    }
150    
151    @Override
152    public String toString() {
153        if(_stringValue == null) {
154            StringBuilder stringValue = new StringBuilder("{");
155            
156            stringValue.append("entityId=").append(getEntityId());
157            
158            stringValue.append(", campaignSourcePK=").append(getCampaignSourcePK());
159            stringValue.append(", campaignSourceName=").append(getCampaignSourceName());
160            stringValue.append(", valueSha1Hash=").append(getValueSha1Hash());
161            stringValue.append(", value=").append(getValue());
162            stringValue.append(", isDefault=").append(getIsDefault());
163            stringValue.append(", sortOrder=").append(getSortOrder());
164            stringValue.append(", fromTime=").append(getFromTime());
165            stringValue.append(", thruTime=").append(getThruTime());
166            
167            stringValue.append('}');
168            
169            _stringValue = stringValue.toString();
170        }
171        return _stringValue;
172    }
173    
174    @Override
175    public boolean equals(Object other) {
176        if(this == other)
177            return true;
178        
179        if(!hasIdentity())
180            return false;
181        
182        if(other instanceof  CampaignSourceDetailValue) {
183            CampaignSourceDetailValue that = (CampaignSourceDetailValue)other;
184            
185            if(!that.hasIdentity())
186                return false;
187            
188            Long thisEntityId = getEntityId();
189            Long thatEntityId = that.getEntityId();
190            
191            boolean objectsEqual = thisEntityId.equals(thatEntityId);
192            if(objectsEqual)
193                objectsEqual = objectsEqual && isIdentical(that);
194            
195            return objectsEqual;
196        } else {
197            return false;
198        }
199    }
200    
201    public boolean isIdentical(Object other) {
202        if(other instanceof CampaignSourceDetailValue) {
203            CampaignSourceDetailValue that = (CampaignSourceDetailValue)other;
204            boolean objectsEqual = true;
205            
206            
207            if(objectsEqual) {
208                CampaignSourcePK thisCampaignSourcePK = getCampaignSourcePK();
209                CampaignSourcePK thatCampaignSourcePK = that.getCampaignSourcePK();
210                
211                if(thisCampaignSourcePK == null) {
212                    objectsEqual = objectsEqual && (thatCampaignSourcePK == null);
213                } else {
214                    objectsEqual = objectsEqual && thisCampaignSourcePK.equals(thatCampaignSourcePK);
215                }
216            }
217            
218            if(objectsEqual) {
219                String thisCampaignSourceName = getCampaignSourceName();
220                String thatCampaignSourceName = that.getCampaignSourceName();
221                
222                if(thisCampaignSourceName == null) {
223                    objectsEqual = objectsEqual && (thatCampaignSourceName == null);
224                } else {
225                    objectsEqual = objectsEqual && thisCampaignSourceName.equals(thatCampaignSourceName);
226                }
227            }
228            
229            if(objectsEqual) {
230                String thisValueSha1Hash = getValueSha1Hash();
231                String thatValueSha1Hash = that.getValueSha1Hash();
232                
233                if(thisValueSha1Hash == null) {
234                    objectsEqual = objectsEqual && (thatValueSha1Hash == null);
235                } else {
236                    objectsEqual = objectsEqual && thisValueSha1Hash.equals(thatValueSha1Hash);
237                }
238            }
239            
240            if(objectsEqual) {
241                String thisValue = getValue();
242                String thatValue = that.getValue();
243                
244                if(thisValue == null) {
245                    objectsEqual = objectsEqual && (thatValue == null);
246                } else {
247                    objectsEqual = objectsEqual && thisValue.equals(thatValue);
248                }
249            }
250            
251            if(objectsEqual) {
252                Boolean thisIsDefault = getIsDefault();
253                Boolean thatIsDefault = that.getIsDefault();
254                
255                if(thisIsDefault == null) {
256                    objectsEqual = objectsEqual && (thatIsDefault == null);
257                } else {
258                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
259                }
260            }
261            
262            if(objectsEqual) {
263                Integer thisSortOrder = getSortOrder();
264                Integer thatSortOrder = that.getSortOrder();
265                
266                if(thisSortOrder == null) {
267                    objectsEqual = objectsEqual && (thatSortOrder == null);
268                } else {
269                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
270                }
271            }
272            
273            if(objectsEqual) {
274                Long thisFromTime = getFromTime();
275                Long thatFromTime = that.getFromTime();
276                
277                if(thisFromTime == null) {
278                    objectsEqual = objectsEqual && (thatFromTime == null);
279                } else {
280                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
281                }
282            }
283            
284            if(objectsEqual) {
285                Long thisThruTime = getThruTime();
286                Long thatThruTime = that.getThruTime();
287                
288                if(thisThruTime == null) {
289                    objectsEqual = objectsEqual && (thatThruTime == null);
290                } else {
291                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
292                }
293            }
294            
295            return objectsEqual;
296        } else {
297            return false;
298        }
299    }
300    
301    @Override
302    public boolean hasBeenModified() {
303        return campaignSourcePKHasBeenModified || campaignSourceNameHasBeenModified || valueSha1HashHasBeenModified || valueHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
304    }
305    
306    @Override
307    public void clearHasBeenModified() {
308        campaignSourcePKHasBeenModified = false;
309        campaignSourceNameHasBeenModified = false;
310        valueSha1HashHasBeenModified = false;
311        valueHasBeenModified = false;
312        isDefaultHasBeenModified = false;
313        sortOrderHasBeenModified = false;
314        fromTimeHasBeenModified = false;
315        thruTimeHasBeenModified = false;
316    }
317    
318    public CampaignSourcePK getCampaignSourcePK() {
319        return campaignSourcePK;
320    }
321    
322    public void setCampaignSourcePK(CampaignSourcePK campaignSourcePK)
323            throws PersistenceNotNullException {
324        checkForNull(campaignSourcePK);
325        
326        boolean update = true;
327        
328        if(this.campaignSourcePK != null) {
329            if(this.campaignSourcePK.equals(campaignSourcePK)) {
330                update = false;
331            }
332        } else if(campaignSourcePK == null) {
333            update = false;
334        }
335        
336        if(update) {
337            this.campaignSourcePK = campaignSourcePK;
338            campaignSourcePKHasBeenModified = true;
339            clearHashAndString();
340        }
341    }
342    
343    public boolean getCampaignSourcePKHasBeenModified() {
344        return campaignSourcePKHasBeenModified;
345    }
346    
347    public String getCampaignSourceName() {
348        return campaignSourceName;
349    }
350    
351    public void setCampaignSourceName(String campaignSourceName)
352            throws PersistenceNotNullException {
353        checkForNull(campaignSourceName);
354        
355        boolean update = true;
356        
357        if(this.campaignSourceName != null) {
358            if(this.campaignSourceName.equals(campaignSourceName)) {
359                update = false;
360            }
361        } else if(campaignSourceName == null) {
362            update = false;
363        }
364        
365        if(update) {
366            this.campaignSourceName = campaignSourceName;
367            campaignSourceNameHasBeenModified = true;
368            clearHashAndString();
369        }
370    }
371    
372    public boolean getCampaignSourceNameHasBeenModified() {
373        return campaignSourceNameHasBeenModified;
374    }
375    
376    public String getValueSha1Hash() {
377        return valueSha1Hash;
378    }
379    
380    public void setValueSha1Hash(String valueSha1Hash)
381            throws PersistenceNotNullException {
382        checkForNull(valueSha1Hash);
383        
384        boolean update = true;
385        
386        if(this.valueSha1Hash != null) {
387            if(this.valueSha1Hash.equals(valueSha1Hash)) {
388                update = false;
389            }
390        } else if(valueSha1Hash == null) {
391            update = false;
392        }
393        
394        if(update) {
395            this.valueSha1Hash = valueSha1Hash;
396            valueSha1HashHasBeenModified = true;
397            clearHashAndString();
398        }
399    }
400    
401    public boolean getValueSha1HashHasBeenModified() {
402        return valueSha1HashHasBeenModified;
403    }
404    
405    public String getValue() {
406        return value;
407    }
408    
409    public void setValue(String value)
410            throws PersistenceNotNullException {
411        checkForNull(value);
412        
413        boolean update = true;
414        
415        if(this.value != null) {
416            if(this.value.equals(value)) {
417                update = false;
418            }
419        } else if(value == null) {
420            update = false;
421        }
422        
423        if(update) {
424            this.value = value;
425            valueHasBeenModified = true;
426            clearHashAndString();
427        }
428    }
429    
430    public boolean getValueHasBeenModified() {
431        return valueHasBeenModified;
432    }
433    
434    public Boolean getIsDefault() {
435        return isDefault;
436    }
437    
438    public void setIsDefault(Boolean isDefault)
439            throws PersistenceNotNullException {
440        checkForNull(isDefault);
441        
442        boolean update = true;
443        
444        if(this.isDefault != null) {
445            if(this.isDefault.equals(isDefault)) {
446                update = false;
447            }
448        } else if(isDefault == null) {
449            update = false;
450        }
451        
452        if(update) {
453            this.isDefault = isDefault;
454            isDefaultHasBeenModified = true;
455            clearHashAndString();
456        }
457    }
458    
459    public boolean getIsDefaultHasBeenModified() {
460        return isDefaultHasBeenModified;
461    }
462    
463    public Integer getSortOrder() {
464        return sortOrder;
465    }
466    
467    public void setSortOrder(Integer sortOrder)
468            throws PersistenceNotNullException {
469        checkForNull(sortOrder);
470        
471        boolean update = true;
472        
473        if(this.sortOrder != null) {
474            if(this.sortOrder.equals(sortOrder)) {
475                update = false;
476            }
477        } else if(sortOrder == null) {
478            update = false;
479        }
480        
481        if(update) {
482            this.sortOrder = sortOrder;
483            sortOrderHasBeenModified = true;
484            clearHashAndString();
485        }
486    }
487    
488    public boolean getSortOrderHasBeenModified() {
489        return sortOrderHasBeenModified;
490    }
491    
492    public Long getFromTime() {
493        return fromTime;
494    }
495    
496    public void setFromTime(Long fromTime)
497            throws PersistenceNotNullException {
498        checkForNull(fromTime);
499        
500        boolean update = true;
501        
502        if(this.fromTime != null) {
503            if(this.fromTime.equals(fromTime)) {
504                update = false;
505            }
506        } else if(fromTime == null) {
507            update = false;
508        }
509        
510        if(update) {
511            this.fromTime = fromTime;
512            fromTimeHasBeenModified = true;
513            clearHashAndString();
514        }
515    }
516    
517    public boolean getFromTimeHasBeenModified() {
518        return fromTimeHasBeenModified;
519    }
520    
521    public Long getThruTime() {
522        return thruTime;
523    }
524    
525    public void setThruTime(Long thruTime)
526            throws PersistenceNotNullException {
527        checkForNull(thruTime);
528        
529        boolean update = true;
530        
531        if(this.thruTime != null) {
532            if(this.thruTime.equals(thruTime)) {
533                update = false;
534            }
535        } else if(thruTime == null) {
536            update = false;
537        }
538        
539        if(update) {
540            this.thruTime = thruTime;
541            thruTimeHasBeenModified = true;
542            clearHashAndString();
543        }
544    }
545    
546    public boolean getThruTimeHasBeenModified() {
547        return thruTimeHasBeenModified;
548    }
549    
550}