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 * 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
038public class OfferTimeValue
039        extends BaseValue<OfferTimePK>
040        implements Cloneable, Serializable {
041    
042    private OfferPK offerPK;
043    private boolean offerPKHasBeenModified = false;
044    private Long lastEvaluationTime;
045    private boolean lastEvaluationTimeHasBeenModified = false;
046    private Long maxItemCreatedTime;
047    private boolean maxItemCreatedTimeHasBeenModified = false;
048    private Long maxItemModifiedTime;
049    private boolean maxItemModifiedTimeHasBeenModified = false;
050    private Long maxItemDeletedTime;
051    private boolean maxItemDeletedTimeHasBeenModified = false;
052    
053    private transient Integer _hashCode = null;
054    private transient String _stringValue = null;
055    
056    private void constructFields(OfferPK offerPK, Long lastEvaluationTime, Long maxItemCreatedTime, Long maxItemModifiedTime, Long maxItemDeletedTime)
057            throws PersistenceNotNullException {
058        checkForNull(offerPK);
059        this.offerPK = offerPK;
060        this.lastEvaluationTime = lastEvaluationTime;
061        this.maxItemCreatedTime = maxItemCreatedTime;
062        this.maxItemModifiedTime = maxItemModifiedTime;
063        this.maxItemDeletedTime = maxItemDeletedTime;
064    }
065    
066    /** Creates a new instance of OfferTimeValue */
067    public OfferTimeValue(OfferTimePK offerTimePK, OfferPK offerPK, Long lastEvaluationTime, Long maxItemCreatedTime, Long maxItemModifiedTime, Long maxItemDeletedTime)
068            throws PersistenceNotNullException {
069        super(offerTimePK);
070        constructFields(offerPK, lastEvaluationTime, maxItemCreatedTime, maxItemModifiedTime, maxItemDeletedTime);
071    }
072    
073    /** Creates a new instance of OfferTimeValue */
074    public OfferTimeValue(OfferPK offerPK, Long lastEvaluationTime, Long maxItemCreatedTime, Long maxItemModifiedTime, Long maxItemDeletedTime)
075            throws PersistenceNotNullException {
076        super();
077        constructFields(offerPK, lastEvaluationTime, maxItemCreatedTime, maxItemModifiedTime, maxItemDeletedTime);
078    }
079    
080   @Override
081   public OfferTimeFactory getBaseFactoryInstance() {
082        return OfferTimeFactory.getInstance();
083    }
084    
085    @Override
086    public OfferTimeValue 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 (OfferTimeValue)result;
097    }
098    
099   @Override
100    public OfferTimePK getPrimaryKey() {
101        if(_primaryKey == null) {
102            _primaryKey = new OfferTimePK(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 + ((offerPK != null) ? offerPK.hashCode() : 0);
121            hashCode = 37 * hashCode + ((lastEvaluationTime != null) ? lastEvaluationTime.hashCode() : 0);
122            hashCode = 37 * hashCode + ((maxItemCreatedTime != null) ? maxItemCreatedTime.hashCode() : 0);
123            hashCode = 37 * hashCode + ((maxItemModifiedTime != null) ? maxItemModifiedTime.hashCode() : 0);
124            hashCode = 37 * hashCode + ((maxItemDeletedTime != null) ? maxItemDeletedTime.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(", offerPK=").append(getOfferPK());
140            stringValue.append(", lastEvaluationTime=").append(getLastEvaluationTime());
141            stringValue.append(", maxItemCreatedTime=").append(getMaxItemCreatedTime());
142            stringValue.append(", maxItemModifiedTime=").append(getMaxItemModifiedTime());
143            stringValue.append(", maxItemDeletedTime=").append(getMaxItemDeletedTime());
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  OfferTimeValue) {
161            OfferTimeValue that = (OfferTimeValue)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 OfferTimeValue) {
181            OfferTimeValue that = (OfferTimeValue)other;
182            boolean objectsEqual = true;
183            
184            
185            if(objectsEqual) {
186                OfferPK thisOfferPK = getOfferPK();
187                OfferPK thatOfferPK = that.getOfferPK();
188                
189                if(thisOfferPK == null) {
190                    objectsEqual = objectsEqual && (thatOfferPK == null);
191                } else {
192                    objectsEqual = objectsEqual && thisOfferPK.equals(thatOfferPK);
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 thisMaxItemCreatedTime = getMaxItemCreatedTime();
209                Long thatMaxItemCreatedTime = that.getMaxItemCreatedTime();
210                
211                if(thisMaxItemCreatedTime == null) {
212                    objectsEqual = objectsEqual && (thatMaxItemCreatedTime == null);
213                } else {
214                    objectsEqual = objectsEqual && thisMaxItemCreatedTime.equals(thatMaxItemCreatedTime);
215                }
216            }
217            
218            if(objectsEqual) {
219                Long thisMaxItemModifiedTime = getMaxItemModifiedTime();
220                Long thatMaxItemModifiedTime = that.getMaxItemModifiedTime();
221                
222                if(thisMaxItemModifiedTime == null) {
223                    objectsEqual = objectsEqual && (thatMaxItemModifiedTime == null);
224                } else {
225                    objectsEqual = objectsEqual && thisMaxItemModifiedTime.equals(thatMaxItemModifiedTime);
226                }
227            }
228            
229            if(objectsEqual) {
230                Long thisMaxItemDeletedTime = getMaxItemDeletedTime();
231                Long thatMaxItemDeletedTime = that.getMaxItemDeletedTime();
232                
233                if(thisMaxItemDeletedTime == null) {
234                    objectsEqual = objectsEqual && (thatMaxItemDeletedTime == null);
235                } else {
236                    objectsEqual = objectsEqual && thisMaxItemDeletedTime.equals(thatMaxItemDeletedTime);
237                }
238            }
239            
240            return objectsEqual;
241        } else {
242            return false;
243        }
244    }
245    
246    @Override
247    public boolean hasBeenModified() {
248        return offerPKHasBeenModified || lastEvaluationTimeHasBeenModified || maxItemCreatedTimeHasBeenModified || maxItemModifiedTimeHasBeenModified || maxItemDeletedTimeHasBeenModified;
249    }
250    
251    @Override
252    public void clearHasBeenModified() {
253        offerPKHasBeenModified = false;
254        lastEvaluationTimeHasBeenModified = false;
255        maxItemCreatedTimeHasBeenModified = false;
256        maxItemModifiedTimeHasBeenModified = false;
257        maxItemDeletedTimeHasBeenModified = false;
258    }
259    
260    public OfferPK getOfferPK() {
261        return offerPK;
262    }
263    
264    public void setOfferPK(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    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 getMaxItemCreatedTime() {
316        return maxItemCreatedTime;
317    }
318    
319    public void setMaxItemCreatedTime(Long maxItemCreatedTime) {
320        boolean update = true;
321        
322        if(this.maxItemCreatedTime != null) {
323            if(this.maxItemCreatedTime.equals(maxItemCreatedTime)) {
324                update = false;
325            }
326        } else if(maxItemCreatedTime == null) {
327            update = false;
328        }
329        
330        if(update) {
331            this.maxItemCreatedTime = maxItemCreatedTime;
332            maxItemCreatedTimeHasBeenModified = true;
333            clearHashAndString();
334        }
335    }
336    
337    public boolean getMaxItemCreatedTimeHasBeenModified() {
338        return maxItemCreatedTimeHasBeenModified;
339    }
340    
341    public Long getMaxItemModifiedTime() {
342        return maxItemModifiedTime;
343    }
344    
345    public void setMaxItemModifiedTime(Long maxItemModifiedTime) {
346        boolean update = true;
347        
348        if(this.maxItemModifiedTime != null) {
349            if(this.maxItemModifiedTime.equals(maxItemModifiedTime)) {
350                update = false;
351            }
352        } else if(maxItemModifiedTime == null) {
353            update = false;
354        }
355        
356        if(update) {
357            this.maxItemModifiedTime = maxItemModifiedTime;
358            maxItemModifiedTimeHasBeenModified = true;
359            clearHashAndString();
360        }
361    }
362    
363    public boolean getMaxItemModifiedTimeHasBeenModified() {
364        return maxItemModifiedTimeHasBeenModified;
365    }
366    
367    public Long getMaxItemDeletedTime() {
368        return maxItemDeletedTime;
369    }
370    
371    public void setMaxItemDeletedTime(Long maxItemDeletedTime) {
372        boolean update = true;
373        
374        if(this.maxItemDeletedTime != null) {
375            if(this.maxItemDeletedTime.equals(maxItemDeletedTime)) {
376                update = false;
377            }
378        } else if(maxItemDeletedTime == null) {
379            update = false;
380        }
381        
382        if(update) {
383            this.maxItemDeletedTime = maxItemDeletedTime;
384            maxItemDeletedTimeHasBeenModified = true;
385            clearHashAndString();
386        }
387    }
388    
389    public boolean getMaxItemDeletedTimeHasBeenModified() {
390        return maxItemDeletedTimeHasBeenModified;
391    }
392    
393}