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 * 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            _stringValue = "{" + 
136                    "entityId=" + getEntityId() +
137                    ", selectorPK=" + getSelectorPK() +
138                    ", lastEvaluationTime=" + getLastEvaluationTime() +
139                    ", maxEntityCreatedTime=" + getMaxEntityCreatedTime() +
140                    ", maxEntityModifiedTime=" + getMaxEntityModifiedTime() +
141                    ", maxEntityDeletedTime=" + getMaxEntityDeletedTime() +
142                    "}";
143        }
144        return _stringValue;
145    }
146    
147    @Override
148    public boolean equals(Object other) {
149        if(this == other)
150            return true;
151        
152        if(!hasIdentity())
153            return false;
154        
155        if(other instanceof  SelectorTimeValue that) {
156            if(!that.hasIdentity())
157                return false;
158            
159            Long thisEntityId = getEntityId();
160            Long thatEntityId = that.getEntityId();
161            
162            boolean objectsEqual = thisEntityId.equals(thatEntityId);
163            if(objectsEqual)
164                objectsEqual = isIdentical(that);
165            
166            return objectsEqual;
167        } else {
168            return false;
169        }
170    }
171    
172    public boolean isIdentical(Object other) {
173        if(other instanceof SelectorTimeValue that) {
174            boolean objectsEqual = true;
175            
176            
177            if(objectsEqual) {
178                SelectorPK thisSelectorPK = getSelectorPK();
179                SelectorPK thatSelectorPK = that.getSelectorPK();
180                
181                if(thisSelectorPK == null) {
182                    objectsEqual = objectsEqual && (thatSelectorPK == null);
183                } else {
184                    objectsEqual = objectsEqual && thisSelectorPK.equals(thatSelectorPK);
185                }
186            }
187            
188            if(objectsEqual) {
189                Long thisLastEvaluationTime = getLastEvaluationTime();
190                Long thatLastEvaluationTime = that.getLastEvaluationTime();
191                
192                if(thisLastEvaluationTime == null) {
193                    objectsEqual = objectsEqual && (thatLastEvaluationTime == null);
194                } else {
195                    objectsEqual = objectsEqual && thisLastEvaluationTime.equals(thatLastEvaluationTime);
196                }
197            }
198            
199            if(objectsEqual) {
200                Long thisMaxEntityCreatedTime = getMaxEntityCreatedTime();
201                Long thatMaxEntityCreatedTime = that.getMaxEntityCreatedTime();
202                
203                if(thisMaxEntityCreatedTime == null) {
204                    objectsEqual = objectsEqual && (thatMaxEntityCreatedTime == null);
205                } else {
206                    objectsEqual = objectsEqual && thisMaxEntityCreatedTime.equals(thatMaxEntityCreatedTime);
207                }
208            }
209            
210            if(objectsEqual) {
211                Long thisMaxEntityModifiedTime = getMaxEntityModifiedTime();
212                Long thatMaxEntityModifiedTime = that.getMaxEntityModifiedTime();
213                
214                if(thisMaxEntityModifiedTime == null) {
215                    objectsEqual = objectsEqual && (thatMaxEntityModifiedTime == null);
216                } else {
217                    objectsEqual = objectsEqual && thisMaxEntityModifiedTime.equals(thatMaxEntityModifiedTime);
218                }
219            }
220            
221            if(objectsEqual) {
222                Long thisMaxEntityDeletedTime = getMaxEntityDeletedTime();
223                Long thatMaxEntityDeletedTime = that.getMaxEntityDeletedTime();
224                
225                if(thisMaxEntityDeletedTime == null) {
226                    objectsEqual = objectsEqual && (thatMaxEntityDeletedTime == null);
227                } else {
228                    objectsEqual = objectsEqual && thisMaxEntityDeletedTime.equals(thatMaxEntityDeletedTime);
229                }
230            }
231            
232            return objectsEqual;
233        } else {
234            return false;
235        }
236    }
237    
238    @Override
239    public boolean hasBeenModified() {
240        return selectorPKHasBeenModified || lastEvaluationTimeHasBeenModified || maxEntityCreatedTimeHasBeenModified || maxEntityModifiedTimeHasBeenModified || maxEntityDeletedTimeHasBeenModified;
241    }
242    
243    @Override
244    public void clearHasBeenModified() {
245        selectorPKHasBeenModified = false;
246        lastEvaluationTimeHasBeenModified = false;
247        maxEntityCreatedTimeHasBeenModified = false;
248        maxEntityModifiedTimeHasBeenModified = false;
249        maxEntityDeletedTimeHasBeenModified = false;
250    }
251    
252    public SelectorPK getSelectorPK() {
253        return selectorPK;
254    }
255    
256    public void setSelectorPK(SelectorPK selectorPK)
257            throws PersistenceNotNullException {
258        checkForNull(selectorPK);
259        
260        boolean update = true;
261        
262        if(this.selectorPK != null) {
263            if(this.selectorPK.equals(selectorPK)) {
264                update = false;
265            }
266        } else if(selectorPK == null) {
267            update = false;
268        }
269        
270        if(update) {
271            this.selectorPK = selectorPK;
272            selectorPKHasBeenModified = true;
273            clearHashAndString();
274        }
275    }
276    
277    public boolean getSelectorPKHasBeenModified() {
278        return selectorPKHasBeenModified;
279    }
280    
281    public Long getLastEvaluationTime() {
282        return lastEvaluationTime;
283    }
284    
285    public void setLastEvaluationTime(Long lastEvaluationTime) {
286        boolean update = true;
287        
288        if(this.lastEvaluationTime != null) {
289            if(this.lastEvaluationTime.equals(lastEvaluationTime)) {
290                update = false;
291            }
292        } else if(lastEvaluationTime == null) {
293            update = false;
294        }
295        
296        if(update) {
297            this.lastEvaluationTime = lastEvaluationTime;
298            lastEvaluationTimeHasBeenModified = true;
299            clearHashAndString();
300        }
301    }
302    
303    public boolean getLastEvaluationTimeHasBeenModified() {
304        return lastEvaluationTimeHasBeenModified;
305    }
306    
307    public Long getMaxEntityCreatedTime() {
308        return maxEntityCreatedTime;
309    }
310    
311    public void setMaxEntityCreatedTime(Long maxEntityCreatedTime) {
312        boolean update = true;
313        
314        if(this.maxEntityCreatedTime != null) {
315            if(this.maxEntityCreatedTime.equals(maxEntityCreatedTime)) {
316                update = false;
317            }
318        } else if(maxEntityCreatedTime == null) {
319            update = false;
320        }
321        
322        if(update) {
323            this.maxEntityCreatedTime = maxEntityCreatedTime;
324            maxEntityCreatedTimeHasBeenModified = true;
325            clearHashAndString();
326        }
327    }
328    
329    public boolean getMaxEntityCreatedTimeHasBeenModified() {
330        return maxEntityCreatedTimeHasBeenModified;
331    }
332    
333    public Long getMaxEntityModifiedTime() {
334        return maxEntityModifiedTime;
335    }
336    
337    public void setMaxEntityModifiedTime(Long maxEntityModifiedTime) {
338        boolean update = true;
339        
340        if(this.maxEntityModifiedTime != null) {
341            if(this.maxEntityModifiedTime.equals(maxEntityModifiedTime)) {
342                update = false;
343            }
344        } else if(maxEntityModifiedTime == null) {
345            update = false;
346        }
347        
348        if(update) {
349            this.maxEntityModifiedTime = maxEntityModifiedTime;
350            maxEntityModifiedTimeHasBeenModified = true;
351            clearHashAndString();
352        }
353    }
354    
355    public boolean getMaxEntityModifiedTimeHasBeenModified() {
356        return maxEntityModifiedTimeHasBeenModified;
357    }
358    
359    public Long getMaxEntityDeletedTime() {
360        return maxEntityDeletedTime;
361    }
362    
363    public void setMaxEntityDeletedTime(Long maxEntityDeletedTime) {
364        boolean update = true;
365        
366        if(this.maxEntityDeletedTime != null) {
367            if(this.maxEntityDeletedTime.equals(maxEntityDeletedTime)) {
368                update = false;
369            }
370        } else if(maxEntityDeletedTime == null) {
371            update = false;
372        }
373        
374        if(update) {
375            this.maxEntityDeletedTime = maxEntityDeletedTime;
376            maxEntityDeletedTimeHasBeenModified = true;
377            clearHashAndString();
378        }
379    }
380    
381    public boolean getMaxEntityDeletedTimeHasBeenModified() {
382        return maxEntityDeletedTimeHasBeenModified;
383    }
384    
385}