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 * UnitOfMeasureEquivalentValue.java
021 */
022
023package com.echothree.model.data.uom.server.value;
024
025import com.echothree.model.data.uom.common.pk.UnitOfMeasureEquivalentPK;
026
027import com.echothree.model.data.uom.server.factory.UnitOfMeasureEquivalentFactory;
028
029import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK;
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 UnitOfMeasureEquivalentValue
039        extends BaseValue<UnitOfMeasureEquivalentPK>
040        implements Cloneable, Serializable {
041    
042    private UnitOfMeasureTypePK fromUnitOfMeasureTypePK;
043    private boolean fromUnitOfMeasureTypePKHasBeenModified = false;
044    private UnitOfMeasureTypePK toUnitOfMeasureTypePK;
045    private boolean toUnitOfMeasureTypePKHasBeenModified = false;
046    private Long toQuantity;
047    private boolean toQuantityHasBeenModified = false;
048    private Long fromTime;
049    private boolean fromTimeHasBeenModified = false;
050    private Long thruTime;
051    private boolean thruTimeHasBeenModified = false;
052    
053    private transient Integer _hashCode = null;
054    private transient String _stringValue = null;
055    
056    private void constructFields(UnitOfMeasureTypePK fromUnitOfMeasureTypePK, UnitOfMeasureTypePK toUnitOfMeasureTypePK, Long toQuantity, Long fromTime, Long thruTime)
057            throws PersistenceNotNullException {
058        checkForNull(fromUnitOfMeasureTypePK);
059        this.fromUnitOfMeasureTypePK = fromUnitOfMeasureTypePK;
060        checkForNull(toUnitOfMeasureTypePK);
061        this.toUnitOfMeasureTypePK = toUnitOfMeasureTypePK;
062        checkForNull(toQuantity);
063        this.toQuantity = toQuantity;
064        checkForNull(fromTime);
065        this.fromTime = fromTime;
066        checkForNull(thruTime);
067        this.thruTime = thruTime;
068    }
069    
070    /** Creates a new instance of UnitOfMeasureEquivalentValue */
071    public UnitOfMeasureEquivalentValue(UnitOfMeasureEquivalentPK unitOfMeasureEquivalentPK, UnitOfMeasureTypePK fromUnitOfMeasureTypePK, UnitOfMeasureTypePK toUnitOfMeasureTypePK, Long toQuantity, Long fromTime, Long thruTime)
072            throws PersistenceNotNullException {
073        super(unitOfMeasureEquivalentPK);
074        constructFields(fromUnitOfMeasureTypePK, toUnitOfMeasureTypePK, toQuantity, fromTime, thruTime);
075    }
076    
077    /** Creates a new instance of UnitOfMeasureEquivalentValue */
078    public UnitOfMeasureEquivalentValue(UnitOfMeasureTypePK fromUnitOfMeasureTypePK, UnitOfMeasureTypePK toUnitOfMeasureTypePK, Long toQuantity, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super();
081        constructFields(fromUnitOfMeasureTypePK, toUnitOfMeasureTypePK, toQuantity, fromTime, thruTime);
082    }
083    
084   @Override
085   public UnitOfMeasureEquivalentFactory getBaseFactoryInstance() {
086        return UnitOfMeasureEquivalentFactory.getInstance();
087    }
088    
089    @Override
090    public UnitOfMeasureEquivalentValue clone() {
091        Object result;
092        
093        try {
094            result = super.clone();
095        } catch (CloneNotSupportedException cnse) {
096            // This shouldn't happen, fail when it does.
097            throw new PersistenceCloneException(cnse);
098        }
099        
100        return (UnitOfMeasureEquivalentValue)result;
101    }
102    
103   @Override
104    public UnitOfMeasureEquivalentPK getPrimaryKey() {
105        if(_primaryKey == null) {
106            _primaryKey = new UnitOfMeasureEquivalentPK(entityId);
107        }
108        
109        return _primaryKey;
110    }
111    
112    private void clearHashAndString() {
113        _hashCode = null;
114        _stringValue = null;
115    }
116    
117    @Override
118    public int hashCode() {
119        if(_hashCode == null) {
120            int hashCode = 17;
121            
122            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
123            
124            hashCode = 37 * hashCode + ((fromUnitOfMeasureTypePK != null) ? fromUnitOfMeasureTypePK.hashCode() : 0);
125            hashCode = 37 * hashCode + ((toUnitOfMeasureTypePK != null) ? toUnitOfMeasureTypePK.hashCode() : 0);
126            hashCode = 37 * hashCode + ((toQuantity != null) ? toQuantity.hashCode() : 0);
127            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
128            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
129            
130            _hashCode = hashCode;
131        }
132        
133        return _hashCode;
134    }
135    
136    @Override
137    public String toString() {
138        if(_stringValue == null) {
139            StringBuilder stringValue = new StringBuilder("{");
140            
141            stringValue.append("entityId=").append(getEntityId());
142            
143            stringValue.append(", fromUnitOfMeasureTypePK=").append(getFromUnitOfMeasureTypePK());
144            stringValue.append(", toUnitOfMeasureTypePK=").append(getToUnitOfMeasureTypePK());
145            stringValue.append(", toQuantity=").append(getToQuantity());
146            stringValue.append(", fromTime=").append(getFromTime());
147            stringValue.append(", thruTime=").append(getThruTime());
148            
149            stringValue.append('}');
150            
151            _stringValue = stringValue.toString();
152        }
153        return _stringValue;
154    }
155    
156    @Override
157    public boolean equals(Object other) {
158        if(this == other)
159            return true;
160        
161        if(!hasIdentity())
162            return false;
163        
164        if(other instanceof  UnitOfMeasureEquivalentValue) {
165            UnitOfMeasureEquivalentValue that = (UnitOfMeasureEquivalentValue)other;
166            
167            if(!that.hasIdentity())
168                return false;
169            
170            Long thisEntityId = getEntityId();
171            Long thatEntityId = that.getEntityId();
172            
173            boolean objectsEqual = thisEntityId.equals(thatEntityId);
174            if(objectsEqual)
175                objectsEqual = objectsEqual && isIdentical(that);
176            
177            return objectsEqual;
178        } else {
179            return false;
180        }
181    }
182    
183    public boolean isIdentical(Object other) {
184        if(other instanceof UnitOfMeasureEquivalentValue) {
185            UnitOfMeasureEquivalentValue that = (UnitOfMeasureEquivalentValue)other;
186            boolean objectsEqual = true;
187            
188            
189            if(objectsEqual) {
190                UnitOfMeasureTypePK thisFromUnitOfMeasureTypePK = getFromUnitOfMeasureTypePK();
191                UnitOfMeasureTypePK thatFromUnitOfMeasureTypePK = that.getFromUnitOfMeasureTypePK();
192                
193                if(thisFromUnitOfMeasureTypePK == null) {
194                    objectsEqual = objectsEqual && (thatFromUnitOfMeasureTypePK == null);
195                } else {
196                    objectsEqual = objectsEqual && thisFromUnitOfMeasureTypePK.equals(thatFromUnitOfMeasureTypePK);
197                }
198            }
199            
200            if(objectsEqual) {
201                UnitOfMeasureTypePK thisToUnitOfMeasureTypePK = getToUnitOfMeasureTypePK();
202                UnitOfMeasureTypePK thatToUnitOfMeasureTypePK = that.getToUnitOfMeasureTypePK();
203                
204                if(thisToUnitOfMeasureTypePK == null) {
205                    objectsEqual = objectsEqual && (thatToUnitOfMeasureTypePK == null);
206                } else {
207                    objectsEqual = objectsEqual && thisToUnitOfMeasureTypePK.equals(thatToUnitOfMeasureTypePK);
208                }
209            }
210            
211            if(objectsEqual) {
212                Long thisToQuantity = getToQuantity();
213                Long thatToQuantity = that.getToQuantity();
214                
215                if(thisToQuantity == null) {
216                    objectsEqual = objectsEqual && (thatToQuantity == null);
217                } else {
218                    objectsEqual = objectsEqual && thisToQuantity.equals(thatToQuantity);
219                }
220            }
221            
222            if(objectsEqual) {
223                Long thisFromTime = getFromTime();
224                Long thatFromTime = that.getFromTime();
225                
226                if(thisFromTime == null) {
227                    objectsEqual = objectsEqual && (thatFromTime == null);
228                } else {
229                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
230                }
231            }
232            
233            if(objectsEqual) {
234                Long thisThruTime = getThruTime();
235                Long thatThruTime = that.getThruTime();
236                
237                if(thisThruTime == null) {
238                    objectsEqual = objectsEqual && (thatThruTime == null);
239                } else {
240                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
241                }
242            }
243            
244            return objectsEqual;
245        } else {
246            return false;
247        }
248    }
249    
250    @Override
251    public boolean hasBeenModified() {
252        return fromUnitOfMeasureTypePKHasBeenModified || toUnitOfMeasureTypePKHasBeenModified || toQuantityHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
253    }
254    
255    @Override
256    public void clearHasBeenModified() {
257        fromUnitOfMeasureTypePKHasBeenModified = false;
258        toUnitOfMeasureTypePKHasBeenModified = false;
259        toQuantityHasBeenModified = false;
260        fromTimeHasBeenModified = false;
261        thruTimeHasBeenModified = false;
262    }
263    
264    public UnitOfMeasureTypePK getFromUnitOfMeasureTypePK() {
265        return fromUnitOfMeasureTypePK;
266    }
267    
268    public void setFromUnitOfMeasureTypePK(UnitOfMeasureTypePK fromUnitOfMeasureTypePK)
269            throws PersistenceNotNullException {
270        checkForNull(fromUnitOfMeasureTypePK);
271        
272        boolean update = true;
273        
274        if(this.fromUnitOfMeasureTypePK != null) {
275            if(this.fromUnitOfMeasureTypePK.equals(fromUnitOfMeasureTypePK)) {
276                update = false;
277            }
278        } else if(fromUnitOfMeasureTypePK == null) {
279            update = false;
280        }
281        
282        if(update) {
283            this.fromUnitOfMeasureTypePK = fromUnitOfMeasureTypePK;
284            fromUnitOfMeasureTypePKHasBeenModified = true;
285            clearHashAndString();
286        }
287    }
288    
289    public boolean getFromUnitOfMeasureTypePKHasBeenModified() {
290        return fromUnitOfMeasureTypePKHasBeenModified;
291    }
292    
293    public UnitOfMeasureTypePK getToUnitOfMeasureTypePK() {
294        return toUnitOfMeasureTypePK;
295    }
296    
297    public void setToUnitOfMeasureTypePK(UnitOfMeasureTypePK toUnitOfMeasureTypePK)
298            throws PersistenceNotNullException {
299        checkForNull(toUnitOfMeasureTypePK);
300        
301        boolean update = true;
302        
303        if(this.toUnitOfMeasureTypePK != null) {
304            if(this.toUnitOfMeasureTypePK.equals(toUnitOfMeasureTypePK)) {
305                update = false;
306            }
307        } else if(toUnitOfMeasureTypePK == null) {
308            update = false;
309        }
310        
311        if(update) {
312            this.toUnitOfMeasureTypePK = toUnitOfMeasureTypePK;
313            toUnitOfMeasureTypePKHasBeenModified = true;
314            clearHashAndString();
315        }
316    }
317    
318    public boolean getToUnitOfMeasureTypePKHasBeenModified() {
319        return toUnitOfMeasureTypePKHasBeenModified;
320    }
321    
322    public Long getToQuantity() {
323        return toQuantity;
324    }
325    
326    public void setToQuantity(Long toQuantity)
327            throws PersistenceNotNullException {
328        checkForNull(toQuantity);
329        
330        boolean update = true;
331        
332        if(this.toQuantity != null) {
333            if(this.toQuantity.equals(toQuantity)) {
334                update = false;
335            }
336        } else if(toQuantity == null) {
337            update = false;
338        }
339        
340        if(update) {
341            this.toQuantity = toQuantity;
342            toQuantityHasBeenModified = true;
343            clearHashAndString();
344        }
345    }
346    
347    public boolean getToQuantityHasBeenModified() {
348        return toQuantityHasBeenModified;
349    }
350    
351    public Long getFromTime() {
352        return fromTime;
353    }
354    
355    public void setFromTime(Long fromTime)
356            throws PersistenceNotNullException {
357        checkForNull(fromTime);
358        
359        boolean update = true;
360        
361        if(this.fromTime != null) {
362            if(this.fromTime.equals(fromTime)) {
363                update = false;
364            }
365        } else if(fromTime == null) {
366            update = false;
367        }
368        
369        if(update) {
370            this.fromTime = fromTime;
371            fromTimeHasBeenModified = true;
372            clearHashAndString();
373        }
374    }
375    
376    public boolean getFromTimeHasBeenModified() {
377        return fromTimeHasBeenModified;
378    }
379    
380    public Long getThruTime() {
381        return thruTime;
382    }
383    
384    public void setThruTime(Long thruTime)
385            throws PersistenceNotNullException {
386        checkForNull(thruTime);
387        
388        boolean update = true;
389        
390        if(this.thruTime != null) {
391            if(this.thruTime.equals(thruTime)) {
392                update = false;
393            }
394        } else if(thruTime == null) {
395            update = false;
396        }
397        
398        if(update) {
399            this.thruTime = thruTime;
400            thruTimeHasBeenModified = true;
401            clearHashAndString();
402        }
403    }
404    
405    public boolean getThruTimeHasBeenModified() {
406        return thruTimeHasBeenModified;
407    }
408    
409}