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 * EntityAttributeIntegerValue.java
021 */
022
023package com.echothree.model.data.core.server.value;
024
025import com.echothree.model.data.core.common.pk.EntityAttributeIntegerPK;
026
027import com.echothree.model.data.core.server.factory.EntityAttributeIntegerFactory;
028
029import com.echothree.model.data.core.common.pk.EntityAttributePK;
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 EntityAttributeIntegerValue
039        extends BaseValue<EntityAttributeIntegerPK>
040        implements Cloneable, Serializable {
041    
042    private EntityAttributePK entityAttributePK;
043    private boolean entityAttributePKHasBeenModified = false;
044    private Integer upperRangeIntegerValue;
045    private boolean upperRangeIntegerValueHasBeenModified = false;
046    private Integer upperLimitIntegerValue;
047    private boolean upperLimitIntegerValueHasBeenModified = false;
048    private Integer lowerLimitIntegerValue;
049    private boolean lowerLimitIntegerValueHasBeenModified = false;
050    private Integer lowerRangeIntegerValue;
051    private boolean lowerRangeIntegerValueHasBeenModified = false;
052    private Long fromTime;
053    private boolean fromTimeHasBeenModified = false;
054    private Long thruTime;
055    private boolean thruTimeHasBeenModified = false;
056    
057    private transient Integer _hashCode = null;
058    private transient String _stringValue = null;
059    
060    private void constructFields(EntityAttributePK entityAttributePK, Integer upperRangeIntegerValue, Integer upperLimitIntegerValue, Integer lowerLimitIntegerValue, Integer lowerRangeIntegerValue, Long fromTime, Long thruTime)
061            throws PersistenceNotNullException {
062        checkForNull(entityAttributePK);
063        this.entityAttributePK = entityAttributePK;
064        this.upperRangeIntegerValue = upperRangeIntegerValue;
065        this.upperLimitIntegerValue = upperLimitIntegerValue;
066        this.lowerLimitIntegerValue = lowerLimitIntegerValue;
067        this.lowerRangeIntegerValue = lowerRangeIntegerValue;
068        checkForNull(fromTime);
069        this.fromTime = fromTime;
070        checkForNull(thruTime);
071        this.thruTime = thruTime;
072    }
073    
074    /** Creates a new instance of EntityAttributeIntegerValue */
075    public EntityAttributeIntegerValue(EntityAttributeIntegerPK entityAttributeIntegerPK, EntityAttributePK entityAttributePK, Integer upperRangeIntegerValue, Integer upperLimitIntegerValue, Integer lowerLimitIntegerValue, Integer lowerRangeIntegerValue, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super(entityAttributeIntegerPK);
078        constructFields(entityAttributePK, upperRangeIntegerValue, upperLimitIntegerValue, lowerLimitIntegerValue, lowerRangeIntegerValue, fromTime, thruTime);
079    }
080    
081    /** Creates a new instance of EntityAttributeIntegerValue */
082    public EntityAttributeIntegerValue(EntityAttributePK entityAttributePK, Integer upperRangeIntegerValue, Integer upperLimitIntegerValue, Integer lowerLimitIntegerValue, Integer lowerRangeIntegerValue, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super();
085        constructFields(entityAttributePK, upperRangeIntegerValue, upperLimitIntegerValue, lowerLimitIntegerValue, lowerRangeIntegerValue, fromTime, thruTime);
086    }
087    
088   @Override
089   public EntityAttributeIntegerFactory getBaseFactoryInstance() {
090        return EntityAttributeIntegerFactory.getInstance();
091    }
092    
093    @Override
094    public EntityAttributeIntegerValue clone() {
095        Object result;
096        
097        try {
098            result = super.clone();
099        } catch (CloneNotSupportedException cnse) {
100            // This shouldn't happen, fail when it does.
101            throw new PersistenceCloneException(cnse);
102        }
103        
104        return (EntityAttributeIntegerValue)result;
105    }
106    
107   @Override
108    public EntityAttributeIntegerPK getPrimaryKey() {
109        if(_primaryKey == null) {
110            _primaryKey = new EntityAttributeIntegerPK(entityId);
111        }
112        
113        return _primaryKey;
114    }
115    
116    private void clearHashAndString() {
117        _hashCode = null;
118        _stringValue = null;
119    }
120    
121    @Override
122    public int hashCode() {
123        if(_hashCode == null) {
124            int hashCode = 17;
125            
126            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
127            
128            hashCode = 37 * hashCode + ((entityAttributePK != null) ? entityAttributePK.hashCode() : 0);
129            hashCode = 37 * hashCode + ((upperRangeIntegerValue != null) ? upperRangeIntegerValue.hashCode() : 0);
130            hashCode = 37 * hashCode + ((upperLimitIntegerValue != null) ? upperLimitIntegerValue.hashCode() : 0);
131            hashCode = 37 * hashCode + ((lowerLimitIntegerValue != null) ? lowerLimitIntegerValue.hashCode() : 0);
132            hashCode = 37 * hashCode + ((lowerRangeIntegerValue != null) ? lowerRangeIntegerValue.hashCode() : 0);
133            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
134            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
135            
136            _hashCode = hashCode;
137        }
138        
139        return _hashCode;
140    }
141    
142    @Override
143    public String toString() {
144        if(_stringValue == null) {
145            StringBuilder stringValue = new StringBuilder("{");
146            
147            stringValue.append("entityId=").append(getEntityId());
148            
149            stringValue.append(", entityAttributePK=").append(getEntityAttributePK());
150            stringValue.append(", upperRangeIntegerValue=").append(getUpperRangeIntegerValue());
151            stringValue.append(", upperLimitIntegerValue=").append(getUpperLimitIntegerValue());
152            stringValue.append(", lowerLimitIntegerValue=").append(getLowerLimitIntegerValue());
153            stringValue.append(", lowerRangeIntegerValue=").append(getLowerRangeIntegerValue());
154            stringValue.append(", fromTime=").append(getFromTime());
155            stringValue.append(", thruTime=").append(getThruTime());
156            
157            stringValue.append('}');
158            
159            _stringValue = stringValue.toString();
160        }
161        return _stringValue;
162    }
163    
164    @Override
165    public boolean equals(Object other) {
166        if(this == other)
167            return true;
168        
169        if(!hasIdentity())
170            return false;
171        
172        if(other instanceof  EntityAttributeIntegerValue) {
173            EntityAttributeIntegerValue that = (EntityAttributeIntegerValue)other;
174            
175            if(!that.hasIdentity())
176                return false;
177            
178            Long thisEntityId = getEntityId();
179            Long thatEntityId = that.getEntityId();
180            
181            boolean objectsEqual = thisEntityId.equals(thatEntityId);
182            if(objectsEqual)
183                objectsEqual = objectsEqual && isIdentical(that);
184            
185            return objectsEqual;
186        } else {
187            return false;
188        }
189    }
190    
191    public boolean isIdentical(Object other) {
192        if(other instanceof EntityAttributeIntegerValue) {
193            EntityAttributeIntegerValue that = (EntityAttributeIntegerValue)other;
194            boolean objectsEqual = true;
195            
196            
197            if(objectsEqual) {
198                EntityAttributePK thisEntityAttributePK = getEntityAttributePK();
199                EntityAttributePK thatEntityAttributePK = that.getEntityAttributePK();
200                
201                if(thisEntityAttributePK == null) {
202                    objectsEqual = objectsEqual && (thatEntityAttributePK == null);
203                } else {
204                    objectsEqual = objectsEqual && thisEntityAttributePK.equals(thatEntityAttributePK);
205                }
206            }
207            
208            if(objectsEqual) {
209                Integer thisUpperRangeIntegerValue = getUpperRangeIntegerValue();
210                Integer thatUpperRangeIntegerValue = that.getUpperRangeIntegerValue();
211                
212                if(thisUpperRangeIntegerValue == null) {
213                    objectsEqual = objectsEqual && (thatUpperRangeIntegerValue == null);
214                } else {
215                    objectsEqual = objectsEqual && thisUpperRangeIntegerValue.equals(thatUpperRangeIntegerValue);
216                }
217            }
218            
219            if(objectsEqual) {
220                Integer thisUpperLimitIntegerValue = getUpperLimitIntegerValue();
221                Integer thatUpperLimitIntegerValue = that.getUpperLimitIntegerValue();
222                
223                if(thisUpperLimitIntegerValue == null) {
224                    objectsEqual = objectsEqual && (thatUpperLimitIntegerValue == null);
225                } else {
226                    objectsEqual = objectsEqual && thisUpperLimitIntegerValue.equals(thatUpperLimitIntegerValue);
227                }
228            }
229            
230            if(objectsEqual) {
231                Integer thisLowerLimitIntegerValue = getLowerLimitIntegerValue();
232                Integer thatLowerLimitIntegerValue = that.getLowerLimitIntegerValue();
233                
234                if(thisLowerLimitIntegerValue == null) {
235                    objectsEqual = objectsEqual && (thatLowerLimitIntegerValue == null);
236                } else {
237                    objectsEqual = objectsEqual && thisLowerLimitIntegerValue.equals(thatLowerLimitIntegerValue);
238                }
239            }
240            
241            if(objectsEqual) {
242                Integer thisLowerRangeIntegerValue = getLowerRangeIntegerValue();
243                Integer thatLowerRangeIntegerValue = that.getLowerRangeIntegerValue();
244                
245                if(thisLowerRangeIntegerValue == null) {
246                    objectsEqual = objectsEqual && (thatLowerRangeIntegerValue == null);
247                } else {
248                    objectsEqual = objectsEqual && thisLowerRangeIntegerValue.equals(thatLowerRangeIntegerValue);
249                }
250            }
251            
252            if(objectsEqual) {
253                Long thisFromTime = getFromTime();
254                Long thatFromTime = that.getFromTime();
255                
256                if(thisFromTime == null) {
257                    objectsEqual = objectsEqual && (thatFromTime == null);
258                } else {
259                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
260                }
261            }
262            
263            if(objectsEqual) {
264                Long thisThruTime = getThruTime();
265                Long thatThruTime = that.getThruTime();
266                
267                if(thisThruTime == null) {
268                    objectsEqual = objectsEqual && (thatThruTime == null);
269                } else {
270                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
271                }
272            }
273            
274            return objectsEqual;
275        } else {
276            return false;
277        }
278    }
279    
280    @Override
281    public boolean hasBeenModified() {
282        return entityAttributePKHasBeenModified || upperRangeIntegerValueHasBeenModified || upperLimitIntegerValueHasBeenModified || lowerLimitIntegerValueHasBeenModified || lowerRangeIntegerValueHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
283    }
284    
285    @Override
286    public void clearHasBeenModified() {
287        entityAttributePKHasBeenModified = false;
288        upperRangeIntegerValueHasBeenModified = false;
289        upperLimitIntegerValueHasBeenModified = false;
290        lowerLimitIntegerValueHasBeenModified = false;
291        lowerRangeIntegerValueHasBeenModified = false;
292        fromTimeHasBeenModified = false;
293        thruTimeHasBeenModified = false;
294    }
295    
296    public EntityAttributePK getEntityAttributePK() {
297        return entityAttributePK;
298    }
299    
300    public void setEntityAttributePK(EntityAttributePK entityAttributePK)
301            throws PersistenceNotNullException {
302        checkForNull(entityAttributePK);
303        
304        boolean update = true;
305        
306        if(this.entityAttributePK != null) {
307            if(this.entityAttributePK.equals(entityAttributePK)) {
308                update = false;
309            }
310        } else if(entityAttributePK == null) {
311            update = false;
312        }
313        
314        if(update) {
315            this.entityAttributePK = entityAttributePK;
316            entityAttributePKHasBeenModified = true;
317            clearHashAndString();
318        }
319    }
320    
321    public boolean getEntityAttributePKHasBeenModified() {
322        return entityAttributePKHasBeenModified;
323    }
324    
325    public Integer getUpperRangeIntegerValue() {
326        return upperRangeIntegerValue;
327    }
328    
329    public void setUpperRangeIntegerValue(Integer upperRangeIntegerValue) {
330        boolean update = true;
331        
332        if(this.upperRangeIntegerValue != null) {
333            if(this.upperRangeIntegerValue.equals(upperRangeIntegerValue)) {
334                update = false;
335            }
336        } else if(upperRangeIntegerValue == null) {
337            update = false;
338        }
339        
340        if(update) {
341            this.upperRangeIntegerValue = upperRangeIntegerValue;
342            upperRangeIntegerValueHasBeenModified = true;
343            clearHashAndString();
344        }
345    }
346    
347    public boolean getUpperRangeIntegerValueHasBeenModified() {
348        return upperRangeIntegerValueHasBeenModified;
349    }
350    
351    public Integer getUpperLimitIntegerValue() {
352        return upperLimitIntegerValue;
353    }
354    
355    public void setUpperLimitIntegerValue(Integer upperLimitIntegerValue) {
356        boolean update = true;
357        
358        if(this.upperLimitIntegerValue != null) {
359            if(this.upperLimitIntegerValue.equals(upperLimitIntegerValue)) {
360                update = false;
361            }
362        } else if(upperLimitIntegerValue == null) {
363            update = false;
364        }
365        
366        if(update) {
367            this.upperLimitIntegerValue = upperLimitIntegerValue;
368            upperLimitIntegerValueHasBeenModified = true;
369            clearHashAndString();
370        }
371    }
372    
373    public boolean getUpperLimitIntegerValueHasBeenModified() {
374        return upperLimitIntegerValueHasBeenModified;
375    }
376    
377    public Integer getLowerLimitIntegerValue() {
378        return lowerLimitIntegerValue;
379    }
380    
381    public void setLowerLimitIntegerValue(Integer lowerLimitIntegerValue) {
382        boolean update = true;
383        
384        if(this.lowerLimitIntegerValue != null) {
385            if(this.lowerLimitIntegerValue.equals(lowerLimitIntegerValue)) {
386                update = false;
387            }
388        } else if(lowerLimitIntegerValue == null) {
389            update = false;
390        }
391        
392        if(update) {
393            this.lowerLimitIntegerValue = lowerLimitIntegerValue;
394            lowerLimitIntegerValueHasBeenModified = true;
395            clearHashAndString();
396        }
397    }
398    
399    public boolean getLowerLimitIntegerValueHasBeenModified() {
400        return lowerLimitIntegerValueHasBeenModified;
401    }
402    
403    public Integer getLowerRangeIntegerValue() {
404        return lowerRangeIntegerValue;
405    }
406    
407    public void setLowerRangeIntegerValue(Integer lowerRangeIntegerValue) {
408        boolean update = true;
409        
410        if(this.lowerRangeIntegerValue != null) {
411            if(this.lowerRangeIntegerValue.equals(lowerRangeIntegerValue)) {
412                update = false;
413            }
414        } else if(lowerRangeIntegerValue == null) {
415            update = false;
416        }
417        
418        if(update) {
419            this.lowerRangeIntegerValue = lowerRangeIntegerValue;
420            lowerRangeIntegerValueHasBeenModified = true;
421            clearHashAndString();
422        }
423    }
424    
425    public boolean getLowerRangeIntegerValueHasBeenModified() {
426        return lowerRangeIntegerValueHasBeenModified;
427    }
428    
429    public Long getFromTime() {
430        return fromTime;
431    }
432    
433    public void setFromTime(Long fromTime)
434            throws PersistenceNotNullException {
435        checkForNull(fromTime);
436        
437        boolean update = true;
438        
439        if(this.fromTime != null) {
440            if(this.fromTime.equals(fromTime)) {
441                update = false;
442            }
443        } else if(fromTime == null) {
444            update = false;
445        }
446        
447        if(update) {
448            this.fromTime = fromTime;
449            fromTimeHasBeenModified = true;
450            clearHashAndString();
451        }
452    }
453    
454    public boolean getFromTimeHasBeenModified() {
455        return fromTimeHasBeenModified;
456    }
457    
458    public Long getThruTime() {
459        return thruTime;
460    }
461    
462    public void setThruTime(Long thruTime)
463            throws PersistenceNotNullException {
464        checkForNull(thruTime);
465        
466        boolean update = true;
467        
468        if(this.thruTime != null) {
469            if(this.thruTime.equals(thruTime)) {
470                update = false;
471            }
472        } else if(thruTime == null) {
473            update = false;
474        }
475        
476        if(update) {
477            this.thruTime = thruTime;
478            thruTimeHasBeenModified = true;
479            clearHashAndString();
480        }
481    }
482    
483    public boolean getThruTimeHasBeenModified() {
484        return thruTimeHasBeenModified;
485    }
486    
487}