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