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 * 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
040import javax.annotation.Nonnull;
041import javax.annotation.Nullable;
042
043public class WorkflowEntityStatusValue
044        extends BaseValue<WorkflowEntityStatusPK>
045        implements Cloneable, Serializable {
046    
047    private EntityInstancePK entityInstancePK;
048    private boolean entityInstancePKHasBeenModified = false;
049    private WorkflowStepPK workflowStepPK;
050    private boolean workflowStepPKHasBeenModified = false;
051    private WorkEffortScopePK workEffortScopePK;
052    private boolean workEffortScopePKHasBeenModified = false;
053    private Long fromTime;
054    private boolean fromTimeHasBeenModified = false;
055    private Long thruTime;
056    private boolean thruTimeHasBeenModified = false;
057    
058    private transient Integer _hashCode = null;
059    private transient String _stringValue = null;
060    
061    private void constructFields(EntityInstancePK entityInstancePK, WorkflowStepPK workflowStepPK, WorkEffortScopePK workEffortScopePK, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(entityInstancePK);
064        this.entityInstancePK = entityInstancePK;
065        checkForNull(workflowStepPK);
066        this.workflowStepPK = workflowStepPK;
067        this.workEffortScopePK = workEffortScopePK;
068        checkForNull(fromTime);
069        this.fromTime = fromTime;
070        checkForNull(thruTime);
071        this.thruTime = thruTime;
072    }
073    
074    /** Creates a new instance of WorkflowEntityStatusValue */
075    public WorkflowEntityStatusValue(WorkflowEntityStatusPK workflowEntityStatusPK, EntityInstancePK entityInstancePK, WorkflowStepPK workflowStepPK, WorkEffortScopePK workEffortScopePK, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super(workflowEntityStatusPK);
078        constructFields(entityInstancePK, workflowStepPK, workEffortScopePK, fromTime, thruTime);
079    }
080    
081    /** Creates a new instance of WorkflowEntityStatusValue */
082    public WorkflowEntityStatusValue(EntityInstancePK entityInstancePK, WorkflowStepPK workflowStepPK, WorkEffortScopePK workEffortScopePK, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super();
085        constructFields(entityInstancePK, workflowStepPK, workEffortScopePK, fromTime, thruTime);
086    }
087    
088    @Override
089    @Nonnull
090    public WorkflowEntityStatusFactory getBaseFactoryInstance() {
091        return WorkflowEntityStatusFactory.getInstance();
092    }
093    
094    @Override
095    @Nonnull
096    public WorkflowEntityStatusValue clone() {
097        Object result;
098        
099        try {
100            result = super.clone();
101        } catch (CloneNotSupportedException cnse) {
102            // This shouldn't happen, fail when it does.
103            throw new PersistenceCloneException(cnse);
104        }
105        
106        return (WorkflowEntityStatusValue)result;
107    }
108    
109    @Override
110    @Nonnull
111    public WorkflowEntityStatusPK getPrimaryKey() {
112        if(_primaryKey == null) {
113            _primaryKey = new WorkflowEntityStatusPK(entityId);
114        }
115        
116        return _primaryKey;
117    }
118    
119    private void clearHashAndString() {
120        _hashCode = null;
121        _stringValue = null;
122    }
123    
124    @Override
125    public int hashCode() {
126        if(_hashCode == null) {
127            int hashCode = 17;
128            
129            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
130            
131            hashCode = 37 * hashCode + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((workflowStepPK != null) ? workflowStepPK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((workEffortScopePK != null) ? workEffortScopePK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
135            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
136            
137            _hashCode = hashCode;
138        }
139        
140        return _hashCode;
141    }
142    
143    @Override
144    @Nonnull
145    public String toString() {
146        if(_stringValue == null) {
147            _stringValue = "{" + 
148                    "entityId=" + getEntityId() +
149                    ", entityInstancePK=" + getEntityInstancePK() +
150                    ", workflowStepPK=" + getWorkflowStepPK() +
151                    ", workEffortScopePK=" + getWorkEffortScopePK() +
152                    ", fromTime=" + getFromTime() +
153                    ", thruTime=" + getThruTime() +
154                    "}";
155        }
156        return _stringValue;
157    }
158    
159    @Override
160    public boolean equals(Object other) {
161        if(this == other)
162            return true;
163        
164        if(!hasIdentity())
165            return false;
166        
167        if(other instanceof  WorkflowEntityStatusValue that) {
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 = 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 that) {
186            boolean objectsEqual = true;
187            
188            
189            if(objectsEqual) {
190                EntityInstancePK thisEntityInstancePK = getEntityInstancePK();
191                EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK();
192                
193                if(thisEntityInstancePK == null) {
194                    objectsEqual = objectsEqual && (thatEntityInstancePK == null);
195                } else {
196                    objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK);
197                }
198            }
199            
200            if(objectsEqual) {
201                WorkflowStepPK thisWorkflowStepPK = getWorkflowStepPK();
202                WorkflowStepPK thatWorkflowStepPK = that.getWorkflowStepPK();
203                
204                if(thisWorkflowStepPK == null) {
205                    objectsEqual = objectsEqual && (thatWorkflowStepPK == null);
206                } else {
207                    objectsEqual = objectsEqual && thisWorkflowStepPK.equals(thatWorkflowStepPK);
208                }
209            }
210            
211            if(objectsEqual) {
212                WorkEffortScopePK thisWorkEffortScopePK = getWorkEffortScopePK();
213                WorkEffortScopePK thatWorkEffortScopePK = that.getWorkEffortScopePK();
214                
215                if(thisWorkEffortScopePK == null) {
216                    objectsEqual = objectsEqual && (thatWorkEffortScopePK == null);
217                } else {
218                    objectsEqual = objectsEqual && thisWorkEffortScopePK.equals(thatWorkEffortScopePK);
219                }
220            }
221            
222            if(objectsEqual) {
223                Long thisFromTime = getFromTime();
224                Long thatFromTime = that.getFromTime();
225                
226                if(thisFromTime == null) {
227                    objectsEqual = objectsEqual && (thatFromTime == null);
228                } else {
229                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
230                }
231            }
232            
233            if(objectsEqual) {
234                Long thisThruTime = getThruTime();
235                Long thatThruTime = that.getThruTime();
236                
237                if(thisThruTime == null) {
238                    objectsEqual = objectsEqual && (thatThruTime == null);
239                } else {
240                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
241                }
242            }
243            
244            return objectsEqual;
245        } else {
246            return false;
247        }
248    }
249    
250    @Override
251    public boolean hasBeenModified() {
252        return entityInstancePKHasBeenModified || workflowStepPKHasBeenModified || workEffortScopePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
253    }
254    
255    @Override
256    public void clearHasBeenModified() {
257        entityInstancePKHasBeenModified = false;
258        workflowStepPKHasBeenModified = false;
259        workEffortScopePKHasBeenModified = false;
260        fromTimeHasBeenModified = false;
261        thruTimeHasBeenModified = false;
262    }
263    
264    @Nonnull
265    public EntityInstancePK getEntityInstancePK() {
266        return entityInstancePK;
267    }
268    
269    public void setEntityInstancePK(@Nonnull 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    @Nonnull
295    public WorkflowStepPK getWorkflowStepPK() {
296        return workflowStepPK;
297    }
298    
299    public void setWorkflowStepPK(@Nonnull WorkflowStepPK workflowStepPK)
300            throws PersistenceNotNullException {
301        checkForNull(workflowStepPK);
302        
303        boolean update = true;
304        
305        if(this.workflowStepPK != null) {
306            if(this.workflowStepPK.equals(workflowStepPK)) {
307                update = false;
308            }
309        } else if(workflowStepPK == null) {
310            update = false;
311        }
312        
313        if(update) {
314            this.workflowStepPK = workflowStepPK;
315            workflowStepPKHasBeenModified = true;
316            clearHashAndString();
317        }
318    }
319    
320    public boolean getWorkflowStepPKHasBeenModified() {
321        return workflowStepPKHasBeenModified;
322    }
323    
324    @Nullable
325    public WorkEffortScopePK getWorkEffortScopePK() {
326        return workEffortScopePK;
327    }
328    
329    public void setWorkEffortScopePK(@Nullable WorkEffortScopePK workEffortScopePK) {
330        boolean update = true;
331        
332        if(this.workEffortScopePK != null) {
333            if(this.workEffortScopePK.equals(workEffortScopePK)) {
334                update = false;
335            }
336        } else if(workEffortScopePK == null) {
337            update = false;
338        }
339        
340        if(update) {
341            this.workEffortScopePK = workEffortScopePK;
342            workEffortScopePKHasBeenModified = true;
343            clearHashAndString();
344        }
345    }
346    
347    public boolean getWorkEffortScopePKHasBeenModified() {
348        return workEffortScopePKHasBeenModified;
349    }
350    
351    @Nonnull
352    public Long getFromTime() {
353        return fromTime;
354    }
355    
356    public void setFromTime(@Nonnull Long fromTime)
357            throws PersistenceNotNullException {
358        checkForNull(fromTime);
359        
360        boolean update = true;
361        
362        if(this.fromTime != null) {
363            if(this.fromTime.equals(fromTime)) {
364                update = false;
365            }
366        } else if(fromTime == null) {
367            update = false;
368        }
369        
370        if(update) {
371            this.fromTime = fromTime;
372            fromTimeHasBeenModified = true;
373            clearHashAndString();
374        }
375    }
376    
377    public boolean getFromTimeHasBeenModified() {
378        return fromTimeHasBeenModified;
379    }
380    
381    @Nonnull
382    public Long getThruTime() {
383        return thruTime;
384    }
385    
386    public void setThruTime(@Nonnull 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}