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