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 * CommunicationEventRoleValue.java
021 */
022
023package com.echothree.model.data.communication.server.value;
024
025import com.echothree.model.data.communication.common.pk.CommunicationEventRolePK;
026
027import com.echothree.model.data.communication.server.factory.CommunicationEventRoleFactory;
028
029import com.echothree.model.data.communication.common.pk.CommunicationEventPK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.communication.common.pk.CommunicationEventRoleTypePK;
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
040public class CommunicationEventRoleValue
041        extends BaseValue<CommunicationEventRolePK>
042        implements Cloneable, Serializable {
043    
044    private CommunicationEventPK communicationEventPK;
045    private boolean communicationEventPKHasBeenModified = false;
046    private PartyPK partyPK;
047    private boolean partyPKHasBeenModified = false;
048    private CommunicationEventRoleTypePK communicationEventRoleTypePK;
049    private boolean communicationEventRoleTypePKHasBeenModified = false;
050    private Long fromTime;
051    private boolean fromTimeHasBeenModified = false;
052    private Long thruTime;
053    private boolean thruTimeHasBeenModified = false;
054    
055    private transient Integer _hashCode = null;
056    private transient String _stringValue = null;
057    
058    private void constructFields(CommunicationEventPK communicationEventPK, PartyPK partyPK, CommunicationEventRoleTypePK communicationEventRoleTypePK, Long fromTime, Long thruTime)
059            throws PersistenceNotNullException {
060        checkForNull(communicationEventPK);
061        this.communicationEventPK = communicationEventPK;
062        checkForNull(partyPK);
063        this.partyPK = partyPK;
064        checkForNull(communicationEventRoleTypePK);
065        this.communicationEventRoleTypePK = communicationEventRoleTypePK;
066        checkForNull(fromTime);
067        this.fromTime = fromTime;
068        checkForNull(thruTime);
069        this.thruTime = thruTime;
070    }
071    
072    /** Creates a new instance of CommunicationEventRoleValue */
073    public CommunicationEventRoleValue(CommunicationEventRolePK communicationEventRolePK, CommunicationEventPK communicationEventPK, PartyPK partyPK, CommunicationEventRoleTypePK communicationEventRoleTypePK, Long fromTime, Long thruTime)
074            throws PersistenceNotNullException {
075        super(communicationEventRolePK);
076        constructFields(communicationEventPK, partyPK, communicationEventRoleTypePK, fromTime, thruTime);
077    }
078    
079    /** Creates a new instance of CommunicationEventRoleValue */
080    public CommunicationEventRoleValue(CommunicationEventPK communicationEventPK, PartyPK partyPK, CommunicationEventRoleTypePK communicationEventRoleTypePK, Long fromTime, Long thruTime)
081            throws PersistenceNotNullException {
082        super();
083        constructFields(communicationEventPK, partyPK, communicationEventRoleTypePK, fromTime, thruTime);
084    }
085    
086   @Override
087   public CommunicationEventRoleFactory getBaseFactoryInstance() {
088        return CommunicationEventRoleFactory.getInstance();
089    }
090    
091    @Override
092    public CommunicationEventRoleValue clone() {
093        Object result;
094        
095        try {
096            result = super.clone();
097        } catch (CloneNotSupportedException cnse) {
098            // This shouldn't happen, fail when it does.
099            throw new PersistenceCloneException(cnse);
100        }
101        
102        return (CommunicationEventRoleValue)result;
103    }
104    
105   @Override
106    public CommunicationEventRolePK getPrimaryKey() {
107        if(_primaryKey == null) {
108            _primaryKey = new CommunicationEventRolePK(entityId);
109        }
110        
111        return _primaryKey;
112    }
113    
114    private void clearHashAndString() {
115        _hashCode = null;
116        _stringValue = null;
117    }
118    
119    @Override
120    public int hashCode() {
121        if(_hashCode == null) {
122            int hashCode = 17;
123            
124            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
125            
126            hashCode = 37 * hashCode + ((communicationEventPK != null) ? communicationEventPK.hashCode() : 0);
127            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
128            hashCode = 37 * hashCode + ((communicationEventRoleTypePK != null) ? communicationEventRoleTypePK.hashCode() : 0);
129            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
130            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
131            
132            _hashCode = hashCode;
133        }
134        
135        return _hashCode;
136    }
137    
138    @Override
139    public String toString() {
140        if(_stringValue == null) {
141            StringBuilder stringValue = new StringBuilder("{");
142            
143            stringValue.append("entityId=").append(getEntityId());
144            
145            stringValue.append(", communicationEventPK=").append(getCommunicationEventPK());
146            stringValue.append(", partyPK=").append(getPartyPK());
147            stringValue.append(", communicationEventRoleTypePK=").append(getCommunicationEventRoleTypePK());
148            stringValue.append(", fromTime=").append(getFromTime());
149            stringValue.append(", thruTime=").append(getThruTime());
150            
151            stringValue.append('}');
152            
153            _stringValue = stringValue.toString();
154        }
155        return _stringValue;
156    }
157    
158    @Override
159    public boolean equals(Object other) {
160        if(this == other)
161            return true;
162        
163        if(!hasIdentity())
164            return false;
165        
166        if(other instanceof  CommunicationEventRoleValue) {
167            CommunicationEventRoleValue that = (CommunicationEventRoleValue)other;
168            
169            if(!that.hasIdentity())
170                return false;
171            
172            Long thisEntityId = getEntityId();
173            Long thatEntityId = that.getEntityId();
174            
175            boolean objectsEqual = thisEntityId.equals(thatEntityId);
176            if(objectsEqual)
177                objectsEqual = objectsEqual && isIdentical(that);
178            
179            return objectsEqual;
180        } else {
181            return false;
182        }
183    }
184    
185    public boolean isIdentical(Object other) {
186        if(other instanceof CommunicationEventRoleValue) {
187            CommunicationEventRoleValue that = (CommunicationEventRoleValue)other;
188            boolean objectsEqual = true;
189            
190            
191            if(objectsEqual) {
192                CommunicationEventPK thisCommunicationEventPK = getCommunicationEventPK();
193                CommunicationEventPK thatCommunicationEventPK = that.getCommunicationEventPK();
194                
195                if(thisCommunicationEventPK == null) {
196                    objectsEqual = objectsEqual && (thatCommunicationEventPK == null);
197                } else {
198                    objectsEqual = objectsEqual && thisCommunicationEventPK.equals(thatCommunicationEventPK);
199                }
200            }
201            
202            if(objectsEqual) {
203                PartyPK thisPartyPK = getPartyPK();
204                PartyPK thatPartyPK = that.getPartyPK();
205                
206                if(thisPartyPK == null) {
207                    objectsEqual = objectsEqual && (thatPartyPK == null);
208                } else {
209                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
210                }
211            }
212            
213            if(objectsEqual) {
214                CommunicationEventRoleTypePK thisCommunicationEventRoleTypePK = getCommunicationEventRoleTypePK();
215                CommunicationEventRoleTypePK thatCommunicationEventRoleTypePK = that.getCommunicationEventRoleTypePK();
216                
217                if(thisCommunicationEventRoleTypePK == null) {
218                    objectsEqual = objectsEqual && (thatCommunicationEventRoleTypePK == null);
219                } else {
220                    objectsEqual = objectsEqual && thisCommunicationEventRoleTypePK.equals(thatCommunicationEventRoleTypePK);
221                }
222            }
223            
224            if(objectsEqual) {
225                Long thisFromTime = getFromTime();
226                Long thatFromTime = that.getFromTime();
227                
228                if(thisFromTime == null) {
229                    objectsEqual = objectsEqual && (thatFromTime == null);
230                } else {
231                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
232                }
233            }
234            
235            if(objectsEqual) {
236                Long thisThruTime = getThruTime();
237                Long thatThruTime = that.getThruTime();
238                
239                if(thisThruTime == null) {
240                    objectsEqual = objectsEqual && (thatThruTime == null);
241                } else {
242                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
243                }
244            }
245            
246            return objectsEqual;
247        } else {
248            return false;
249        }
250    }
251    
252    @Override
253    public boolean hasBeenModified() {
254        return communicationEventPKHasBeenModified || partyPKHasBeenModified || communicationEventRoleTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
255    }
256    
257    @Override
258    public void clearHasBeenModified() {
259        communicationEventPKHasBeenModified = false;
260        partyPKHasBeenModified = false;
261        communicationEventRoleTypePKHasBeenModified = false;
262        fromTimeHasBeenModified = false;
263        thruTimeHasBeenModified = false;
264    }
265    
266    public CommunicationEventPK getCommunicationEventPK() {
267        return communicationEventPK;
268    }
269    
270    public void setCommunicationEventPK(CommunicationEventPK communicationEventPK)
271            throws PersistenceNotNullException {
272        checkForNull(communicationEventPK);
273        
274        boolean update = true;
275        
276        if(this.communicationEventPK != null) {
277            if(this.communicationEventPK.equals(communicationEventPK)) {
278                update = false;
279            }
280        } else if(communicationEventPK == null) {
281            update = false;
282        }
283        
284        if(update) {
285            this.communicationEventPK = communicationEventPK;
286            communicationEventPKHasBeenModified = true;
287            clearHashAndString();
288        }
289    }
290    
291    public boolean getCommunicationEventPKHasBeenModified() {
292        return communicationEventPKHasBeenModified;
293    }
294    
295    public PartyPK getPartyPK() {
296        return partyPK;
297    }
298    
299    public void setPartyPK(PartyPK partyPK)
300            throws PersistenceNotNullException {
301        checkForNull(partyPK);
302        
303        boolean update = true;
304        
305        if(this.partyPK != null) {
306            if(this.partyPK.equals(partyPK)) {
307                update = false;
308            }
309        } else if(partyPK == null) {
310            update = false;
311        }
312        
313        if(update) {
314            this.partyPK = partyPK;
315            partyPKHasBeenModified = true;
316            clearHashAndString();
317        }
318    }
319    
320    public boolean getPartyPKHasBeenModified() {
321        return partyPKHasBeenModified;
322    }
323    
324    public CommunicationEventRoleTypePK getCommunicationEventRoleTypePK() {
325        return communicationEventRoleTypePK;
326    }
327    
328    public void setCommunicationEventRoleTypePK(CommunicationEventRoleTypePK communicationEventRoleTypePK)
329            throws PersistenceNotNullException {
330        checkForNull(communicationEventRoleTypePK);
331        
332        boolean update = true;
333        
334        if(this.communicationEventRoleTypePK != null) {
335            if(this.communicationEventRoleTypePK.equals(communicationEventRoleTypePK)) {
336                update = false;
337            }
338        } else if(communicationEventRoleTypePK == null) {
339            update = false;
340        }
341        
342        if(update) {
343            this.communicationEventRoleTypePK = communicationEventRoleTypePK;
344            communicationEventRoleTypePKHasBeenModified = true;
345            clearHashAndString();
346        }
347    }
348    
349    public boolean getCommunicationEventRoleTypePKHasBeenModified() {
350        return communicationEventRoleTypePKHasBeenModified;
351    }
352    
353    public Long getFromTime() {
354        return fromTime;
355    }
356    
357    public void setFromTime(Long fromTime)
358            throws PersistenceNotNullException {
359        checkForNull(fromTime);
360        
361        boolean update = true;
362        
363        if(this.fromTime != null) {
364            if(this.fromTime.equals(fromTime)) {
365                update = false;
366            }
367        } else if(fromTime == null) {
368            update = false;
369        }
370        
371        if(update) {
372            this.fromTime = fromTime;
373            fromTimeHasBeenModified = true;
374            clearHashAndString();
375        }
376    }
377    
378    public boolean getFromTimeHasBeenModified() {
379        return fromTimeHasBeenModified;
380    }
381    
382    public Long getThruTime() {
383        return thruTime;
384    }
385    
386    public void setThruTime(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}