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