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