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