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