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 * CommunicationEmailSourceValue.java
021 */
022
023package com.echothree.model.data.communication.server.value;
024
025import com.echothree.model.data.communication.common.pk.CommunicationEmailSourcePK;
026
027import com.echothree.model.data.communication.server.factory.CommunicationEmailSourceFactory;
028
029import com.echothree.model.data.communication.common.pk.CommunicationSourcePK;
030import com.echothree.model.data.core.common.pk.ServerPK;
031import com.echothree.model.data.workeffort.common.pk.WorkEffortScopePK;
032import com.echothree.model.data.selector.common.pk.SelectorPK;
033
034import com.echothree.util.common.exception.PersistenceCloneException;
035import com.echothree.util.common.exception.PersistenceNotNullException;
036
037import com.echothree.util.server.persistence.BaseValue;
038
039import java.io.Serializable;
040
041import javax.annotation.Nonnull;
042import javax.annotation.Nullable;
043
044public class CommunicationEmailSourceValue
045        extends BaseValue<CommunicationEmailSourcePK>
046        implements Cloneable, Serializable {
047    
048    private CommunicationSourcePK communicationSourcePK;
049    private boolean communicationSourcePKHasBeenModified = false;
050    private ServerPK serverPK;
051    private boolean serverPKHasBeenModified = false;
052    private String username;
053    private boolean usernameHasBeenModified = false;
054    private String password;
055    private boolean passwordHasBeenModified = false;
056    private WorkEffortScopePK receiveWorkEffortScopePK;
057    private boolean receiveWorkEffortScopePKHasBeenModified = false;
058    private WorkEffortScopePK sendWorkEffortScopePK;
059    private boolean sendWorkEffortScopePKHasBeenModified = false;
060    private SelectorPK reviewEmployeeSelectorPK;
061    private boolean reviewEmployeeSelectorPKHasBeenModified = 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(CommunicationSourcePK communicationSourcePK, ServerPK serverPK, String username, String password, WorkEffortScopePK receiveWorkEffortScopePK, WorkEffortScopePK sendWorkEffortScopePK, SelectorPK reviewEmployeeSelectorPK, Long fromTime, Long thruTime)
071            throws PersistenceNotNullException {
072        checkForNull(communicationSourcePK);
073        this.communicationSourcePK = communicationSourcePK;
074        checkForNull(serverPK);
075        this.serverPK = serverPK;
076        checkForNull(username);
077        this.username = username;
078        checkForNull(password);
079        this.password = password;
080        checkForNull(receiveWorkEffortScopePK);
081        this.receiveWorkEffortScopePK = receiveWorkEffortScopePK;
082        checkForNull(sendWorkEffortScopePK);
083        this.sendWorkEffortScopePK = sendWorkEffortScopePK;
084        this.reviewEmployeeSelectorPK = reviewEmployeeSelectorPK;
085        checkForNull(fromTime);
086        this.fromTime = fromTime;
087        checkForNull(thruTime);
088        this.thruTime = thruTime;
089    }
090    
091    /** Creates a new instance of CommunicationEmailSourceValue */
092    public CommunicationEmailSourceValue(CommunicationEmailSourcePK communicationEmailSourcePK, CommunicationSourcePK communicationSourcePK, ServerPK serverPK, String username, String password, WorkEffortScopePK receiveWorkEffortScopePK, WorkEffortScopePK sendWorkEffortScopePK, SelectorPK reviewEmployeeSelectorPK, Long fromTime, Long thruTime)
093            throws PersistenceNotNullException {
094        super(communicationEmailSourcePK);
095        constructFields(communicationSourcePK, serverPK, username, password, receiveWorkEffortScopePK, sendWorkEffortScopePK, reviewEmployeeSelectorPK, fromTime, thruTime);
096    }
097    
098    /** Creates a new instance of CommunicationEmailSourceValue */
099    public CommunicationEmailSourceValue(CommunicationSourcePK communicationSourcePK, ServerPK serverPK, String username, String password, WorkEffortScopePK receiveWorkEffortScopePK, WorkEffortScopePK sendWorkEffortScopePK, SelectorPK reviewEmployeeSelectorPK, Long fromTime, Long thruTime)
100            throws PersistenceNotNullException {
101        super();
102        constructFields(communicationSourcePK, serverPK, username, password, receiveWorkEffortScopePK, sendWorkEffortScopePK, reviewEmployeeSelectorPK, fromTime, thruTime);
103    }
104    
105    @Override
106    @Nonnull
107    public CommunicationEmailSourceFactory getBaseFactoryInstance() {
108        return CommunicationEmailSourceFactory.getInstance();
109    }
110    
111    @Override
112    @Nonnull
113    public CommunicationEmailSourceValue clone() {
114        Object result;
115        
116        try {
117            result = super.clone();
118        } catch (CloneNotSupportedException cnse) {
119            // This shouldn't happen, fail when it does.
120            throw new PersistenceCloneException(cnse);
121        }
122        
123        return (CommunicationEmailSourceValue)result;
124    }
125    
126    @Override
127    @Nonnull
128    public CommunicationEmailSourcePK getPrimaryKey() {
129        if(_primaryKey == null) {
130            _primaryKey = new CommunicationEmailSourcePK(entityId);
131        }
132        
133        return _primaryKey;
134    }
135    
136    private void clearHashAndString() {
137        _hashCode = null;
138        _stringValue = null;
139    }
140    
141    @Override
142    public int hashCode() {
143        if(_hashCode == null) {
144            int hashCode = 17;
145            
146            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
147            
148            hashCode = 37 * hashCode + ((communicationSourcePK != null) ? communicationSourcePK.hashCode() : 0);
149            hashCode = 37 * hashCode + ((serverPK != null) ? serverPK.hashCode() : 0);
150            hashCode = 37 * hashCode + ((username != null) ? username.hashCode() : 0);
151            hashCode = 37 * hashCode + ((password != null) ? password.hashCode() : 0);
152            hashCode = 37 * hashCode + ((receiveWorkEffortScopePK != null) ? receiveWorkEffortScopePK.hashCode() : 0);
153            hashCode = 37 * hashCode + ((sendWorkEffortScopePK != null) ? sendWorkEffortScopePK.hashCode() : 0);
154            hashCode = 37 * hashCode + ((reviewEmployeeSelectorPK != null) ? reviewEmployeeSelectorPK.hashCode() : 0);
155            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
156            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
157            
158            _hashCode = hashCode;
159        }
160        
161        return _hashCode;
162    }
163    
164    @Override
165    @Nonnull
166    public String toString() {
167        if(_stringValue == null) {
168            _stringValue = "{" + 
169                    "entityId=" + getEntityId() +
170                    ", communicationSourcePK=" + getCommunicationSourcePK() +
171                    ", serverPK=" + getServerPK() +
172                    ", username=" + getUsername() +
173                    ", password=" + getPassword() +
174                    ", receiveWorkEffortScopePK=" + getReceiveWorkEffortScopePK() +
175                    ", sendWorkEffortScopePK=" + getSendWorkEffortScopePK() +
176                    ", reviewEmployeeSelectorPK=" + getReviewEmployeeSelectorPK() +
177                    ", fromTime=" + getFromTime() +
178                    ", thruTime=" + getThruTime() +
179                    "}";
180        }
181        return _stringValue;
182    }
183    
184    @Override
185    public boolean equals(Object other) {
186        if(this == other)
187            return true;
188        
189        if(!hasIdentity())
190            return false;
191        
192        if(other instanceof  CommunicationEmailSourceValue that) {
193            if(!that.hasIdentity())
194                return false;
195            
196            Long thisEntityId = getEntityId();
197            Long thatEntityId = that.getEntityId();
198            
199            boolean objectsEqual = thisEntityId.equals(thatEntityId);
200            if(objectsEqual)
201                objectsEqual = isIdentical(that);
202            
203            return objectsEqual;
204        } else {
205            return false;
206        }
207    }
208    
209    public boolean isIdentical(Object other) {
210        if(other instanceof CommunicationEmailSourceValue that) {
211            boolean objectsEqual = true;
212            
213            
214            if(objectsEqual) {
215                CommunicationSourcePK thisCommunicationSourcePK = getCommunicationSourcePK();
216                CommunicationSourcePK thatCommunicationSourcePK = that.getCommunicationSourcePK();
217                
218                if(thisCommunicationSourcePK == null) {
219                    objectsEqual = objectsEqual && (thatCommunicationSourcePK == null);
220                } else {
221                    objectsEqual = objectsEqual && thisCommunicationSourcePK.equals(thatCommunicationSourcePK);
222                }
223            }
224            
225            if(objectsEqual) {
226                ServerPK thisServerPK = getServerPK();
227                ServerPK thatServerPK = that.getServerPK();
228                
229                if(thisServerPK == null) {
230                    objectsEqual = objectsEqual && (thatServerPK == null);
231                } else {
232                    objectsEqual = objectsEqual && thisServerPK.equals(thatServerPK);
233                }
234            }
235            
236            if(objectsEqual) {
237                String thisUsername = getUsername();
238                String thatUsername = that.getUsername();
239                
240                if(thisUsername == null) {
241                    objectsEqual = objectsEqual && (thatUsername == null);
242                } else {
243                    objectsEqual = objectsEqual && thisUsername.equals(thatUsername);
244                }
245            }
246            
247            if(objectsEqual) {
248                String thisPassword = getPassword();
249                String thatPassword = that.getPassword();
250                
251                if(thisPassword == null) {
252                    objectsEqual = objectsEqual && (thatPassword == null);
253                } else {
254                    objectsEqual = objectsEqual && thisPassword.equals(thatPassword);
255                }
256            }
257            
258            if(objectsEqual) {
259                WorkEffortScopePK thisReceiveWorkEffortScopePK = getReceiveWorkEffortScopePK();
260                WorkEffortScopePK thatReceiveWorkEffortScopePK = that.getReceiveWorkEffortScopePK();
261                
262                if(thisReceiveWorkEffortScopePK == null) {
263                    objectsEqual = objectsEqual && (thatReceiveWorkEffortScopePK == null);
264                } else {
265                    objectsEqual = objectsEqual && thisReceiveWorkEffortScopePK.equals(thatReceiveWorkEffortScopePK);
266                }
267            }
268            
269            if(objectsEqual) {
270                WorkEffortScopePK thisSendWorkEffortScopePK = getSendWorkEffortScopePK();
271                WorkEffortScopePK thatSendWorkEffortScopePK = that.getSendWorkEffortScopePK();
272                
273                if(thisSendWorkEffortScopePK == null) {
274                    objectsEqual = objectsEqual && (thatSendWorkEffortScopePK == null);
275                } else {
276                    objectsEqual = objectsEqual && thisSendWorkEffortScopePK.equals(thatSendWorkEffortScopePK);
277                }
278            }
279            
280            if(objectsEqual) {
281                SelectorPK thisReviewEmployeeSelectorPK = getReviewEmployeeSelectorPK();
282                SelectorPK thatReviewEmployeeSelectorPK = that.getReviewEmployeeSelectorPK();
283                
284                if(thisReviewEmployeeSelectorPK == null) {
285                    objectsEqual = objectsEqual && (thatReviewEmployeeSelectorPK == null);
286                } else {
287                    objectsEqual = objectsEqual && thisReviewEmployeeSelectorPK.equals(thatReviewEmployeeSelectorPK);
288                }
289            }
290            
291            if(objectsEqual) {
292                Long thisFromTime = getFromTime();
293                Long thatFromTime = that.getFromTime();
294                
295                if(thisFromTime == null) {
296                    objectsEqual = objectsEqual && (thatFromTime == null);
297                } else {
298                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
299                }
300            }
301            
302            if(objectsEqual) {
303                Long thisThruTime = getThruTime();
304                Long thatThruTime = that.getThruTime();
305                
306                if(thisThruTime == null) {
307                    objectsEqual = objectsEqual && (thatThruTime == null);
308                } else {
309                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
310                }
311            }
312            
313            return objectsEqual;
314        } else {
315            return false;
316        }
317    }
318    
319    @Override
320    public boolean hasBeenModified() {
321        return communicationSourcePKHasBeenModified || serverPKHasBeenModified || usernameHasBeenModified || passwordHasBeenModified || receiveWorkEffortScopePKHasBeenModified || sendWorkEffortScopePKHasBeenModified || reviewEmployeeSelectorPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
322    }
323    
324    @Override
325    public void clearHasBeenModified() {
326        communicationSourcePKHasBeenModified = false;
327        serverPKHasBeenModified = false;
328        usernameHasBeenModified = false;
329        passwordHasBeenModified = false;
330        receiveWorkEffortScopePKHasBeenModified = false;
331        sendWorkEffortScopePKHasBeenModified = false;
332        reviewEmployeeSelectorPKHasBeenModified = false;
333        fromTimeHasBeenModified = false;
334        thruTimeHasBeenModified = false;
335    }
336    
337    @Nonnull
338    public CommunicationSourcePK getCommunicationSourcePK() {
339        return communicationSourcePK;
340    }
341    
342    public void setCommunicationSourcePK(@Nonnull CommunicationSourcePK communicationSourcePK)
343            throws PersistenceNotNullException {
344        checkForNull(communicationSourcePK);
345        
346        boolean update = true;
347        
348        if(this.communicationSourcePK != null) {
349            if(this.communicationSourcePK.equals(communicationSourcePK)) {
350                update = false;
351            }
352        } else if(communicationSourcePK == null) {
353            update = false;
354        }
355        
356        if(update) {
357            this.communicationSourcePK = communicationSourcePK;
358            communicationSourcePKHasBeenModified = true;
359            clearHashAndString();
360        }
361    }
362    
363    public boolean getCommunicationSourcePKHasBeenModified() {
364        return communicationSourcePKHasBeenModified;
365    }
366    
367    @Nonnull
368    public ServerPK getServerPK() {
369        return serverPK;
370    }
371    
372    public void setServerPK(@Nonnull ServerPK serverPK)
373            throws PersistenceNotNullException {
374        checkForNull(serverPK);
375        
376        boolean update = true;
377        
378        if(this.serverPK != null) {
379            if(this.serverPK.equals(serverPK)) {
380                update = false;
381            }
382        } else if(serverPK == null) {
383            update = false;
384        }
385        
386        if(update) {
387            this.serverPK = serverPK;
388            serverPKHasBeenModified = true;
389            clearHashAndString();
390        }
391    }
392    
393    public boolean getServerPKHasBeenModified() {
394        return serverPKHasBeenModified;
395    }
396    
397    @Nonnull
398    public String getUsername() {
399        return username;
400    }
401    
402    public void setUsername(@Nonnull String username)
403            throws PersistenceNotNullException {
404        checkForNull(username);
405        
406        boolean update = true;
407        
408        if(this.username != null) {
409            if(this.username.equals(username)) {
410                update = false;
411            }
412        } else if(username == null) {
413            update = false;
414        }
415        
416        if(update) {
417            this.username = username;
418            usernameHasBeenModified = true;
419            clearHashAndString();
420        }
421    }
422    
423    public boolean getUsernameHasBeenModified() {
424        return usernameHasBeenModified;
425    }
426    
427    @Nonnull
428    public String getPassword() {
429        return password;
430    }
431    
432    public void setPassword(@Nonnull String password)
433            throws PersistenceNotNullException {
434        checkForNull(password);
435        
436        boolean update = true;
437        
438        if(this.password != null) {
439            if(this.password.equals(password)) {
440                update = false;
441            }
442        } else if(password == null) {
443            update = false;
444        }
445        
446        if(update) {
447            this.password = password;
448            passwordHasBeenModified = true;
449            clearHashAndString();
450        }
451    }
452    
453    public boolean getPasswordHasBeenModified() {
454        return passwordHasBeenModified;
455    }
456    
457    @Nonnull
458    public WorkEffortScopePK getReceiveWorkEffortScopePK() {
459        return receiveWorkEffortScopePK;
460    }
461    
462    public void setReceiveWorkEffortScopePK(@Nonnull WorkEffortScopePK receiveWorkEffortScopePK)
463            throws PersistenceNotNullException {
464        checkForNull(receiveWorkEffortScopePK);
465        
466        boolean update = true;
467        
468        if(this.receiveWorkEffortScopePK != null) {
469            if(this.receiveWorkEffortScopePK.equals(receiveWorkEffortScopePK)) {
470                update = false;
471            }
472        } else if(receiveWorkEffortScopePK == null) {
473            update = false;
474        }
475        
476        if(update) {
477            this.receiveWorkEffortScopePK = receiveWorkEffortScopePK;
478            receiveWorkEffortScopePKHasBeenModified = true;
479            clearHashAndString();
480        }
481    }
482    
483    public boolean getReceiveWorkEffortScopePKHasBeenModified() {
484        return receiveWorkEffortScopePKHasBeenModified;
485    }
486    
487    @Nonnull
488    public WorkEffortScopePK getSendWorkEffortScopePK() {
489        return sendWorkEffortScopePK;
490    }
491    
492    public void setSendWorkEffortScopePK(@Nonnull WorkEffortScopePK sendWorkEffortScopePK)
493            throws PersistenceNotNullException {
494        checkForNull(sendWorkEffortScopePK);
495        
496        boolean update = true;
497        
498        if(this.sendWorkEffortScopePK != null) {
499            if(this.sendWorkEffortScopePK.equals(sendWorkEffortScopePK)) {
500                update = false;
501            }
502        } else if(sendWorkEffortScopePK == null) {
503            update = false;
504        }
505        
506        if(update) {
507            this.sendWorkEffortScopePK = sendWorkEffortScopePK;
508            sendWorkEffortScopePKHasBeenModified = true;
509            clearHashAndString();
510        }
511    }
512    
513    public boolean getSendWorkEffortScopePKHasBeenModified() {
514        return sendWorkEffortScopePKHasBeenModified;
515    }
516    
517    @Nullable
518    public SelectorPK getReviewEmployeeSelectorPK() {
519        return reviewEmployeeSelectorPK;
520    }
521    
522    public void setReviewEmployeeSelectorPK(@Nullable SelectorPK reviewEmployeeSelectorPK) {
523        boolean update = true;
524        
525        if(this.reviewEmployeeSelectorPK != null) {
526            if(this.reviewEmployeeSelectorPK.equals(reviewEmployeeSelectorPK)) {
527                update = false;
528            }
529        } else if(reviewEmployeeSelectorPK == null) {
530            update = false;
531        }
532        
533        if(update) {
534            this.reviewEmployeeSelectorPK = reviewEmployeeSelectorPK;
535            reviewEmployeeSelectorPKHasBeenModified = true;
536            clearHashAndString();
537        }
538    }
539    
540    public boolean getReviewEmployeeSelectorPKHasBeenModified() {
541        return reviewEmployeeSelectorPKHasBeenModified;
542    }
543    
544    @Nonnull
545    public Long getFromTime() {
546        return fromTime;
547    }
548    
549    public void setFromTime(@Nonnull Long fromTime)
550            throws PersistenceNotNullException {
551        checkForNull(fromTime);
552        
553        boolean update = true;
554        
555        if(this.fromTime != null) {
556            if(this.fromTime.equals(fromTime)) {
557                update = false;
558            }
559        } else if(fromTime == null) {
560            update = false;
561        }
562        
563        if(update) {
564            this.fromTime = fromTime;
565            fromTimeHasBeenModified = true;
566            clearHashAndString();
567        }
568    }
569    
570    public boolean getFromTimeHasBeenModified() {
571        return fromTimeHasBeenModified;
572    }
573    
574    @Nonnull
575    public Long getThruTime() {
576        return thruTime;
577    }
578    
579    public void setThruTime(@Nonnull Long thruTime)
580            throws PersistenceNotNullException {
581        checkForNull(thruTime);
582        
583        boolean update = true;
584        
585        if(this.thruTime != null) {
586            if(this.thruTime.equals(thruTime)) {
587                update = false;
588            }
589        } else if(thruTime == null) {
590            update = false;
591        }
592        
593        if(update) {
594            this.thruTime = thruTime;
595            thruTimeHasBeenModified = true;
596            clearHashAndString();
597        }
598    }
599    
600    public boolean getThruTimeHasBeenModified() {
601        return thruTimeHasBeenModified;
602    }
603    
604}