001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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 * WorkflowTriggerValue.java
021 */
022
023package com.echothree.model.data.workflow.server.value;
024
025import com.echothree.model.data.workflow.common.pk.WorkflowTriggerPK;
026
027import com.echothree.model.data.workflow.server.factory.WorkflowTriggerFactory;
028
029import com.echothree.model.data.workflow.common.pk.WorkflowEntityStatusPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038public class WorkflowTriggerValue
039        extends BaseValue<WorkflowTriggerPK>
040        implements Cloneable, Serializable {
041    
042    private WorkflowEntityStatusPK workflowEntityStatusPK;
043    private boolean workflowEntityStatusPKHasBeenModified = false;
044    private Long triggerTime;
045    private boolean triggerTimeHasBeenModified = false;
046    private Boolean errorsOccurred;
047    private boolean errorsOccurredHasBeenModified = false;
048    
049    private transient Integer _hashCode = null;
050    private transient String _stringValue = null;
051    
052    private void constructFields(WorkflowEntityStatusPK workflowEntityStatusPK, Long triggerTime, Boolean errorsOccurred)
053            throws PersistenceNotNullException {
054        checkForNull(workflowEntityStatusPK);
055        this.workflowEntityStatusPK = workflowEntityStatusPK;
056        checkForNull(triggerTime);
057        this.triggerTime = triggerTime;
058        this.errorsOccurred = errorsOccurred;
059    }
060    
061    /** Creates a new instance of WorkflowTriggerValue */
062    public WorkflowTriggerValue(WorkflowTriggerPK workflowTriggerPK, WorkflowEntityStatusPK workflowEntityStatusPK, Long triggerTime, Boolean errorsOccurred)
063            throws PersistenceNotNullException {
064        super(workflowTriggerPK);
065        constructFields(workflowEntityStatusPK, triggerTime, errorsOccurred);
066    }
067    
068    /** Creates a new instance of WorkflowTriggerValue */
069    public WorkflowTriggerValue(WorkflowEntityStatusPK workflowEntityStatusPK, Long triggerTime, Boolean errorsOccurred)
070            throws PersistenceNotNullException {
071        super();
072        constructFields(workflowEntityStatusPK, triggerTime, errorsOccurred);
073    }
074    
075   @Override
076   public WorkflowTriggerFactory getBaseFactoryInstance() {
077        return WorkflowTriggerFactory.getInstance();
078    }
079    
080    @Override
081    public WorkflowTriggerValue clone() {
082        Object result;
083        
084        try {
085            result = super.clone();
086        } catch (CloneNotSupportedException cnse) {
087            // This shouldn't happen, fail when it does.
088            throw new PersistenceCloneException(cnse);
089        }
090        
091        return (WorkflowTriggerValue)result;
092    }
093    
094   @Override
095    public WorkflowTriggerPK getPrimaryKey() {
096        if(_primaryKey == null) {
097            _primaryKey = new WorkflowTriggerPK(entityId);
098        }
099        
100        return _primaryKey;
101    }
102    
103    private void clearHashAndString() {
104        _hashCode = null;
105        _stringValue = null;
106    }
107    
108    @Override
109    public int hashCode() {
110        if(_hashCode == null) {
111            int hashCode = 17;
112            
113            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
114            
115            hashCode = 37 * hashCode + ((workflowEntityStatusPK != null) ? workflowEntityStatusPK.hashCode() : 0);
116            hashCode = 37 * hashCode + ((triggerTime != null) ? triggerTime.hashCode() : 0);
117            hashCode = 37 * hashCode + ((errorsOccurred != null) ? errorsOccurred.hashCode() : 0);
118            
119            _hashCode = hashCode;
120        }
121        
122        return _hashCode;
123    }
124    
125    @Override
126    public String toString() {
127        if(_stringValue == null) {
128            _stringValue = "{" + 
129                    "entityId=" + getEntityId() +
130                    ", workflowEntityStatusPK=" + getWorkflowEntityStatusPK() +
131                    ", triggerTime=" + getTriggerTime() +
132                    ", errorsOccurred=" + getErrorsOccurred() +
133                    "}";
134        }
135        return _stringValue;
136    }
137    
138    @Override
139    public boolean equals(Object other) {
140        if(this == other)
141            return true;
142        
143        if(!hasIdentity())
144            return false;
145        
146        if(other instanceof  WorkflowTriggerValue that) {
147            if(!that.hasIdentity())
148                return false;
149            
150            Long thisEntityId = getEntityId();
151            Long thatEntityId = that.getEntityId();
152            
153            boolean objectsEqual = thisEntityId.equals(thatEntityId);
154            if(objectsEqual)
155                objectsEqual = isIdentical(that);
156            
157            return objectsEqual;
158        } else {
159            return false;
160        }
161    }
162    
163    public boolean isIdentical(Object other) {
164        if(other instanceof WorkflowTriggerValue that) {
165            boolean objectsEqual = true;
166            
167            
168            if(objectsEqual) {
169                WorkflowEntityStatusPK thisWorkflowEntityStatusPK = getWorkflowEntityStatusPK();
170                WorkflowEntityStatusPK thatWorkflowEntityStatusPK = that.getWorkflowEntityStatusPK();
171                
172                if(thisWorkflowEntityStatusPK == null) {
173                    objectsEqual = objectsEqual && (thatWorkflowEntityStatusPK == null);
174                } else {
175                    objectsEqual = objectsEqual && thisWorkflowEntityStatusPK.equals(thatWorkflowEntityStatusPK);
176                }
177            }
178            
179            if(objectsEqual) {
180                Long thisTriggerTime = getTriggerTime();
181                Long thatTriggerTime = that.getTriggerTime();
182                
183                if(thisTriggerTime == null) {
184                    objectsEqual = objectsEqual && (thatTriggerTime == null);
185                } else {
186                    objectsEqual = objectsEqual && thisTriggerTime.equals(thatTriggerTime);
187                }
188            }
189            
190            if(objectsEqual) {
191                Boolean thisErrorsOccurred = getErrorsOccurred();
192                Boolean thatErrorsOccurred = that.getErrorsOccurred();
193                
194                if(thisErrorsOccurred == null) {
195                    objectsEqual = objectsEqual && (thatErrorsOccurred == null);
196                } else {
197                    objectsEqual = objectsEqual && thisErrorsOccurred.equals(thatErrorsOccurred);
198                }
199            }
200            
201            return objectsEqual;
202        } else {
203            return false;
204        }
205    }
206    
207    @Override
208    public boolean hasBeenModified() {
209        return workflowEntityStatusPKHasBeenModified || triggerTimeHasBeenModified || errorsOccurredHasBeenModified;
210    }
211    
212    @Override
213    public void clearHasBeenModified() {
214        workflowEntityStatusPKHasBeenModified = false;
215        triggerTimeHasBeenModified = false;
216        errorsOccurredHasBeenModified = false;
217    }
218    
219    public WorkflowEntityStatusPK getWorkflowEntityStatusPK() {
220        return workflowEntityStatusPK;
221    }
222    
223    public void setWorkflowEntityStatusPK(WorkflowEntityStatusPK workflowEntityStatusPK)
224            throws PersistenceNotNullException {
225        checkForNull(workflowEntityStatusPK);
226        
227        boolean update = true;
228        
229        if(this.workflowEntityStatusPK != null) {
230            if(this.workflowEntityStatusPK.equals(workflowEntityStatusPK)) {
231                update = false;
232            }
233        } else if(workflowEntityStatusPK == null) {
234            update = false;
235        }
236        
237        if(update) {
238            this.workflowEntityStatusPK = workflowEntityStatusPK;
239            workflowEntityStatusPKHasBeenModified = true;
240            clearHashAndString();
241        }
242    }
243    
244    public boolean getWorkflowEntityStatusPKHasBeenModified() {
245        return workflowEntityStatusPKHasBeenModified;
246    }
247    
248    public Long getTriggerTime() {
249        return triggerTime;
250    }
251    
252    public void setTriggerTime(Long triggerTime)
253            throws PersistenceNotNullException {
254        checkForNull(triggerTime);
255        
256        boolean update = true;
257        
258        if(this.triggerTime != null) {
259            if(this.triggerTime.equals(triggerTime)) {
260                update = false;
261            }
262        } else if(triggerTime == null) {
263            update = false;
264        }
265        
266        if(update) {
267            this.triggerTime = triggerTime;
268            triggerTimeHasBeenModified = true;
269            clearHashAndString();
270        }
271    }
272    
273    public boolean getTriggerTimeHasBeenModified() {
274        return triggerTimeHasBeenModified;
275    }
276    
277    public Boolean getErrorsOccurred() {
278        return errorsOccurred;
279    }
280    
281    public void setErrorsOccurred(Boolean errorsOccurred) {
282        boolean update = true;
283        
284        if(this.errorsOccurred != null) {
285            if(this.errorsOccurred.equals(errorsOccurred)) {
286                update = false;
287            }
288        } else if(errorsOccurred == null) {
289            update = false;
290        }
291        
292        if(update) {
293            this.errorsOccurred = errorsOccurred;
294            errorsOccurredHasBeenModified = true;
295            clearHashAndString();
296        }
297    }
298    
299    public boolean getErrorsOccurredHasBeenModified() {
300        return errorsOccurredHasBeenModified;
301    }
302    
303}