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 * EntityAttributeNumericValue.java
021 */
022
023package com.echothree.model.data.core.server.value;
024
025import com.echothree.model.data.core.common.pk.EntityAttributeNumericPK;
026
027import com.echothree.model.data.core.server.factory.EntityAttributeNumericFactory;
028
029import com.echothree.model.data.core.common.pk.EntityAttributePK;
030import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK;
031
032import com.echothree.util.common.exception.PersistenceCloneException;
033import com.echothree.util.common.exception.PersistenceNotNullException;
034
035import com.echothree.util.server.persistence.BaseValue;
036
037import java.io.Serializable;
038
039public class EntityAttributeNumericValue
040        extends BaseValue<EntityAttributeNumericPK>
041        implements Cloneable, Serializable {
042    
043    private EntityAttributePK entityAttributePK;
044    private boolean entityAttributePKHasBeenModified = false;
045    private UnitOfMeasureTypePK unitOfMeasureTypePK;
046    private boolean unitOfMeasureTypePKHasBeenModified = false;
047    private Long fromTime;
048    private boolean fromTimeHasBeenModified = false;
049    private Long thruTime;
050    private boolean thruTimeHasBeenModified = false;
051    
052    private transient Integer _hashCode = null;
053    private transient String _stringValue = null;
054    
055    private void constructFields(EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime)
056            throws PersistenceNotNullException {
057        checkForNull(entityAttributePK);
058        this.entityAttributePK = entityAttributePK;
059        this.unitOfMeasureTypePK = unitOfMeasureTypePK;
060        checkForNull(fromTime);
061        this.fromTime = fromTime;
062        checkForNull(thruTime);
063        this.thruTime = thruTime;
064    }
065    
066    /** Creates a new instance of EntityAttributeNumericValue */
067    public EntityAttributeNumericValue(EntityAttributeNumericPK entityAttributeNumericPK, EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime)
068            throws PersistenceNotNullException {
069        super(entityAttributeNumericPK);
070        constructFields(entityAttributePK, unitOfMeasureTypePK, fromTime, thruTime);
071    }
072    
073    /** Creates a new instance of EntityAttributeNumericValue */
074    public EntityAttributeNumericValue(EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime)
075            throws PersistenceNotNullException {
076        super();
077        constructFields(entityAttributePK, unitOfMeasureTypePK, fromTime, thruTime);
078    }
079    
080   @Override
081   public EntityAttributeNumericFactory getBaseFactoryInstance() {
082        return EntityAttributeNumericFactory.getInstance();
083    }
084    
085    @Override
086    public EntityAttributeNumericValue 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 (EntityAttributeNumericValue)result;
097    }
098    
099   @Override
100    public EntityAttributeNumericPK getPrimaryKey() {
101        if(_primaryKey == null) {
102            _primaryKey = new EntityAttributeNumericPK(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 + ((entityAttributePK != null) ? entityAttributePK.hashCode() : 0);
121            hashCode = 37 * hashCode + ((unitOfMeasureTypePK != null) ? unitOfMeasureTypePK.hashCode() : 0);
122            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
123            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
124            
125            _hashCode = hashCode;
126        }
127        
128        return _hashCode;
129    }
130    
131    @Override
132    public String toString() {
133        if(_stringValue == null) {
134            StringBuilder stringValue = new StringBuilder("{");
135            
136            stringValue.append("entityId=").append(getEntityId());
137            
138            stringValue.append(", entityAttributePK=").append(getEntityAttributePK());
139            stringValue.append(", unitOfMeasureTypePK=").append(getUnitOfMeasureTypePK());
140            stringValue.append(", fromTime=").append(getFromTime());
141            stringValue.append(", thruTime=").append(getThruTime());
142            
143            stringValue.append('}');
144            
145            _stringValue = stringValue.toString();
146        }
147        return _stringValue;
148    }
149    
150    @Override
151    public boolean equals(Object other) {
152        if(this == other)
153            return true;
154        
155        if(!hasIdentity())
156            return false;
157        
158        if(other instanceof  EntityAttributeNumericValue) {
159            EntityAttributeNumericValue that = (EntityAttributeNumericValue)other;
160            
161            if(!that.hasIdentity())
162                return false;
163            
164            Long thisEntityId = getEntityId();
165            Long thatEntityId = that.getEntityId();
166            
167            boolean objectsEqual = thisEntityId.equals(thatEntityId);
168            if(objectsEqual)
169                objectsEqual = objectsEqual && isIdentical(that);
170            
171            return objectsEqual;
172        } else {
173            return false;
174        }
175    }
176    
177    public boolean isIdentical(Object other) {
178        if(other instanceof EntityAttributeNumericValue) {
179            EntityAttributeNumericValue that = (EntityAttributeNumericValue)other;
180            boolean objectsEqual = true;
181            
182            
183            if(objectsEqual) {
184                EntityAttributePK thisEntityAttributePK = getEntityAttributePK();
185                EntityAttributePK thatEntityAttributePK = that.getEntityAttributePK();
186                
187                if(thisEntityAttributePK == null) {
188                    objectsEqual = objectsEqual && (thatEntityAttributePK == null);
189                } else {
190                    objectsEqual = objectsEqual && thisEntityAttributePK.equals(thatEntityAttributePK);
191                }
192            }
193            
194            if(objectsEqual) {
195                UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK();
196                UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK();
197                
198                if(thisUnitOfMeasureTypePK == null) {
199                    objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null);
200                } else {
201                    objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK);
202                }
203            }
204            
205            if(objectsEqual) {
206                Long thisFromTime = getFromTime();
207                Long thatFromTime = that.getFromTime();
208                
209                if(thisFromTime == null) {
210                    objectsEqual = objectsEqual && (thatFromTime == null);
211                } else {
212                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
213                }
214            }
215            
216            if(objectsEqual) {
217                Long thisThruTime = getThruTime();
218                Long thatThruTime = that.getThruTime();
219                
220                if(thisThruTime == null) {
221                    objectsEqual = objectsEqual && (thatThruTime == null);
222                } else {
223                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
224                }
225            }
226            
227            return objectsEqual;
228        } else {
229            return false;
230        }
231    }
232    
233    @Override
234    public boolean hasBeenModified() {
235        return entityAttributePKHasBeenModified || unitOfMeasureTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
236    }
237    
238    @Override
239    public void clearHasBeenModified() {
240        entityAttributePKHasBeenModified = false;
241        unitOfMeasureTypePKHasBeenModified = false;
242        fromTimeHasBeenModified = false;
243        thruTimeHasBeenModified = false;
244    }
245    
246    public EntityAttributePK getEntityAttributePK() {
247        return entityAttributePK;
248    }
249    
250    public void setEntityAttributePK(EntityAttributePK entityAttributePK)
251            throws PersistenceNotNullException {
252        checkForNull(entityAttributePK);
253        
254        boolean update = true;
255        
256        if(this.entityAttributePK != null) {
257            if(this.entityAttributePK.equals(entityAttributePK)) {
258                update = false;
259            }
260        } else if(entityAttributePK == null) {
261            update = false;
262        }
263        
264        if(update) {
265            this.entityAttributePK = entityAttributePK;
266            entityAttributePKHasBeenModified = true;
267            clearHashAndString();
268        }
269    }
270    
271    public boolean getEntityAttributePKHasBeenModified() {
272        return entityAttributePKHasBeenModified;
273    }
274    
275    public UnitOfMeasureTypePK getUnitOfMeasureTypePK() {
276        return unitOfMeasureTypePK;
277    }
278    
279    public void setUnitOfMeasureTypePK(UnitOfMeasureTypePK unitOfMeasureTypePK) {
280        boolean update = true;
281        
282        if(this.unitOfMeasureTypePK != null) {
283            if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) {
284                update = false;
285            }
286        } else if(unitOfMeasureTypePK == null) {
287            update = false;
288        }
289        
290        if(update) {
291            this.unitOfMeasureTypePK = unitOfMeasureTypePK;
292            unitOfMeasureTypePKHasBeenModified = true;
293            clearHashAndString();
294        }
295    }
296    
297    public boolean getUnitOfMeasureTypePKHasBeenModified() {
298        return unitOfMeasureTypePKHasBeenModified;
299    }
300    
301    public Long getFromTime() {
302        return fromTime;
303    }
304    
305    public void setFromTime(Long fromTime)
306            throws PersistenceNotNullException {
307        checkForNull(fromTime);
308        
309        boolean update = true;
310        
311        if(this.fromTime != null) {
312            if(this.fromTime.equals(fromTime)) {
313                update = false;
314            }
315        } else if(fromTime == null) {
316            update = false;
317        }
318        
319        if(update) {
320            this.fromTime = fromTime;
321            fromTimeHasBeenModified = true;
322            clearHashAndString();
323        }
324    }
325    
326    public boolean getFromTimeHasBeenModified() {
327        return fromTimeHasBeenModified;
328    }
329    
330    public Long getThruTime() {
331        return thruTime;
332    }
333    
334    public void setThruTime(Long thruTime)
335            throws PersistenceNotNullException {
336        checkForNull(thruTime);
337        
338        boolean update = true;
339        
340        if(this.thruTime != null) {
341            if(this.thruTime.equals(thruTime)) {
342                update = false;
343            }
344        } else if(thruTime == null) {
345            update = false;
346        }
347        
348        if(update) {
349            this.thruTime = thruTime;
350            thruTimeHasBeenModified = true;
351            clearHashAndString();
352        }
353    }
354    
355    public boolean getThruTimeHasBeenModified() {
356        return thruTimeHasBeenModified;
357    }
358    
359}