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