001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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 * UnitOfMeasureKindUseValue.java
021 */
022
023package com.echothree.model.data.uom.server.value;
024
025import com.echothree.model.data.uom.common.pk.UnitOfMeasureKindUsePK;
026
027import com.echothree.model.data.uom.server.factory.UnitOfMeasureKindUseFactory;
028
029import com.echothree.model.data.uom.common.pk.UnitOfMeasureKindUseTypePK;
030import com.echothree.model.data.uom.common.pk.UnitOfMeasureKindPK;
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 UnitOfMeasureKindUseValue
040        extends BaseValue<UnitOfMeasureKindUsePK>
041        implements Cloneable, Serializable {
042    
043    private UnitOfMeasureKindUseTypePK unitOfMeasureKindUseTypePK;
044    private boolean unitOfMeasureKindUseTypePKHasBeenModified = false;
045    private UnitOfMeasureKindPK unitOfMeasureKindPK;
046    private boolean unitOfMeasureKindPKHasBeenModified = false;
047    private Boolean isDefault;
048    private boolean isDefaultHasBeenModified = false;
049    private Integer sortOrder;
050    private boolean sortOrderHasBeenModified = false;
051    private Long fromTime;
052    private boolean fromTimeHasBeenModified = false;
053    private Long thruTime;
054    private boolean thruTimeHasBeenModified = false;
055    
056    private transient Integer _hashCode = null;
057    private transient String _stringValue = null;
058    
059    private void constructFields(UnitOfMeasureKindUseTypePK unitOfMeasureKindUseTypePK, UnitOfMeasureKindPK unitOfMeasureKindPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
060            throws PersistenceNotNullException {
061        checkForNull(unitOfMeasureKindUseTypePK);
062        this.unitOfMeasureKindUseTypePK = unitOfMeasureKindUseTypePK;
063        checkForNull(unitOfMeasureKindPK);
064        this.unitOfMeasureKindPK = unitOfMeasureKindPK;
065        checkForNull(isDefault);
066        this.isDefault = isDefault;
067        checkForNull(sortOrder);
068        this.sortOrder = sortOrder;
069        checkForNull(fromTime);
070        this.fromTime = fromTime;
071        checkForNull(thruTime);
072        this.thruTime = thruTime;
073    }
074    
075    /** Creates a new instance of UnitOfMeasureKindUseValue */
076    public UnitOfMeasureKindUseValue(UnitOfMeasureKindUsePK unitOfMeasureKindUsePK, UnitOfMeasureKindUseTypePK unitOfMeasureKindUseTypePK, UnitOfMeasureKindPK unitOfMeasureKindPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
077            throws PersistenceNotNullException {
078        super(unitOfMeasureKindUsePK);
079        constructFields(unitOfMeasureKindUseTypePK, unitOfMeasureKindPK, isDefault, sortOrder, fromTime, thruTime);
080    }
081    
082    /** Creates a new instance of UnitOfMeasureKindUseValue */
083    public UnitOfMeasureKindUseValue(UnitOfMeasureKindUseTypePK unitOfMeasureKindUseTypePK, UnitOfMeasureKindPK unitOfMeasureKindPK, Boolean isDefault, Integer sortOrder, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super();
086        constructFields(unitOfMeasureKindUseTypePK, unitOfMeasureKindPK, isDefault, sortOrder, fromTime, thruTime);
087    }
088    
089   @Override
090   public UnitOfMeasureKindUseFactory getBaseFactoryInstance() {
091        return UnitOfMeasureKindUseFactory.getInstance();
092    }
093    
094    @Override
095    public UnitOfMeasureKindUseValue clone() {
096        Object result;
097        
098        try {
099            result = super.clone();
100        } catch (CloneNotSupportedException cnse) {
101            // This shouldn't happen, fail when it does.
102            throw new PersistenceCloneException(cnse);
103        }
104        
105        return (UnitOfMeasureKindUseValue)result;
106    }
107    
108   @Override
109    public UnitOfMeasureKindUsePK getPrimaryKey() {
110        if(_primaryKey == null) {
111            _primaryKey = new UnitOfMeasureKindUsePK(entityId);
112        }
113        
114        return _primaryKey;
115    }
116    
117    private void clearHashAndString() {
118        _hashCode = null;
119        _stringValue = null;
120    }
121    
122    @Override
123    public int hashCode() {
124        if(_hashCode == null) {
125            int hashCode = 17;
126            
127            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
128            
129            hashCode = 37 * hashCode + ((unitOfMeasureKindUseTypePK != null) ? unitOfMeasureKindUseTypePK.hashCode() : 0);
130            hashCode = 37 * hashCode + ((unitOfMeasureKindPK != null) ? unitOfMeasureKindPK.hashCode() : 0);
131            hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0);
132            hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.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            _stringValue = "{" + 
146                    "entityId=" + getEntityId() +
147                    ", unitOfMeasureKindUseTypePK=" + getUnitOfMeasureKindUseTypePK() +
148                    ", unitOfMeasureKindPK=" + getUnitOfMeasureKindPK() +
149                    ", isDefault=" + getIsDefault() +
150                    ", sortOrder=" + getSortOrder() +
151                    ", fromTime=" + getFromTime() +
152                    ", thruTime=" + getThruTime() +
153                    "}";
154        }
155        return _stringValue;
156    }
157    
158    @Override
159    public boolean equals(Object other) {
160        if(this == other)
161            return true;
162        
163        if(!hasIdentity())
164            return false;
165        
166        if(other instanceof  UnitOfMeasureKindUseValue that) {
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 = isIdentical(that);
176            
177            return objectsEqual;
178        } else {
179            return false;
180        }
181    }
182    
183    public boolean isIdentical(Object other) {
184        if(other instanceof UnitOfMeasureKindUseValue that) {
185            boolean objectsEqual = true;
186            
187            
188            if(objectsEqual) {
189                UnitOfMeasureKindUseTypePK thisUnitOfMeasureKindUseTypePK = getUnitOfMeasureKindUseTypePK();
190                UnitOfMeasureKindUseTypePK thatUnitOfMeasureKindUseTypePK = that.getUnitOfMeasureKindUseTypePK();
191                
192                if(thisUnitOfMeasureKindUseTypePK == null) {
193                    objectsEqual = objectsEqual && (thatUnitOfMeasureKindUseTypePK == null);
194                } else {
195                    objectsEqual = objectsEqual && thisUnitOfMeasureKindUseTypePK.equals(thatUnitOfMeasureKindUseTypePK);
196                }
197            }
198            
199            if(objectsEqual) {
200                UnitOfMeasureKindPK thisUnitOfMeasureKindPK = getUnitOfMeasureKindPK();
201                UnitOfMeasureKindPK thatUnitOfMeasureKindPK = that.getUnitOfMeasureKindPK();
202                
203                if(thisUnitOfMeasureKindPK == null) {
204                    objectsEqual = objectsEqual && (thatUnitOfMeasureKindPK == null);
205                } else {
206                    objectsEqual = objectsEqual && thisUnitOfMeasureKindPK.equals(thatUnitOfMeasureKindPK);
207                }
208            }
209            
210            if(objectsEqual) {
211                Boolean thisIsDefault = getIsDefault();
212                Boolean thatIsDefault = that.getIsDefault();
213                
214                if(thisIsDefault == null) {
215                    objectsEqual = objectsEqual && (thatIsDefault == null);
216                } else {
217                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
218                }
219            }
220            
221            if(objectsEqual) {
222                Integer thisSortOrder = getSortOrder();
223                Integer thatSortOrder = that.getSortOrder();
224                
225                if(thisSortOrder == null) {
226                    objectsEqual = objectsEqual && (thatSortOrder == null);
227                } else {
228                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
229                }
230            }
231            
232            if(objectsEqual) {
233                Long thisFromTime = getFromTime();
234                Long thatFromTime = that.getFromTime();
235                
236                if(thisFromTime == null) {
237                    objectsEqual = objectsEqual && (thatFromTime == null);
238                } else {
239                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
240                }
241            }
242            
243            if(objectsEqual) {
244                Long thisThruTime = getThruTime();
245                Long thatThruTime = that.getThruTime();
246                
247                if(thisThruTime == null) {
248                    objectsEqual = objectsEqual && (thatThruTime == null);
249                } else {
250                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
251                }
252            }
253            
254            return objectsEqual;
255        } else {
256            return false;
257        }
258    }
259    
260    @Override
261    public boolean hasBeenModified() {
262        return unitOfMeasureKindUseTypePKHasBeenModified || unitOfMeasureKindPKHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
263    }
264    
265    @Override
266    public void clearHasBeenModified() {
267        unitOfMeasureKindUseTypePKHasBeenModified = false;
268        unitOfMeasureKindPKHasBeenModified = false;
269        isDefaultHasBeenModified = false;
270        sortOrderHasBeenModified = false;
271        fromTimeHasBeenModified = false;
272        thruTimeHasBeenModified = false;
273    }
274    
275    public UnitOfMeasureKindUseTypePK getUnitOfMeasureKindUseTypePK() {
276        return unitOfMeasureKindUseTypePK;
277    }
278    
279    public void setUnitOfMeasureKindUseTypePK(UnitOfMeasureKindUseTypePK unitOfMeasureKindUseTypePK)
280            throws PersistenceNotNullException {
281        checkForNull(unitOfMeasureKindUseTypePK);
282        
283        boolean update = true;
284        
285        if(this.unitOfMeasureKindUseTypePK != null) {
286            if(this.unitOfMeasureKindUseTypePK.equals(unitOfMeasureKindUseTypePK)) {
287                update = false;
288            }
289        } else if(unitOfMeasureKindUseTypePK == null) {
290            update = false;
291        }
292        
293        if(update) {
294            this.unitOfMeasureKindUseTypePK = unitOfMeasureKindUseTypePK;
295            unitOfMeasureKindUseTypePKHasBeenModified = true;
296            clearHashAndString();
297        }
298    }
299    
300    public boolean getUnitOfMeasureKindUseTypePKHasBeenModified() {
301        return unitOfMeasureKindUseTypePKHasBeenModified;
302    }
303    
304    public UnitOfMeasureKindPK getUnitOfMeasureKindPK() {
305        return unitOfMeasureKindPK;
306    }
307    
308    public void setUnitOfMeasureKindPK(UnitOfMeasureKindPK unitOfMeasureKindPK)
309            throws PersistenceNotNullException {
310        checkForNull(unitOfMeasureKindPK);
311        
312        boolean update = true;
313        
314        if(this.unitOfMeasureKindPK != null) {
315            if(this.unitOfMeasureKindPK.equals(unitOfMeasureKindPK)) {
316                update = false;
317            }
318        } else if(unitOfMeasureKindPK == null) {
319            update = false;
320        }
321        
322        if(update) {
323            this.unitOfMeasureKindPK = unitOfMeasureKindPK;
324            unitOfMeasureKindPKHasBeenModified = true;
325            clearHashAndString();
326        }
327    }
328    
329    public boolean getUnitOfMeasureKindPKHasBeenModified() {
330        return unitOfMeasureKindPKHasBeenModified;
331    }
332    
333    public Boolean getIsDefault() {
334        return isDefault;
335    }
336    
337    public void setIsDefault(Boolean isDefault)
338            throws PersistenceNotNullException {
339        checkForNull(isDefault);
340        
341        boolean update = true;
342        
343        if(this.isDefault != null) {
344            if(this.isDefault.equals(isDefault)) {
345                update = false;
346            }
347        } else if(isDefault == null) {
348            update = false;
349        }
350        
351        if(update) {
352            this.isDefault = isDefault;
353            isDefaultHasBeenModified = true;
354            clearHashAndString();
355        }
356    }
357    
358    public boolean getIsDefaultHasBeenModified() {
359        return isDefaultHasBeenModified;
360    }
361    
362    public Integer getSortOrder() {
363        return sortOrder;
364    }
365    
366    public void setSortOrder(Integer sortOrder)
367            throws PersistenceNotNullException {
368        checkForNull(sortOrder);
369        
370        boolean update = true;
371        
372        if(this.sortOrder != null) {
373            if(this.sortOrder.equals(sortOrder)) {
374                update = false;
375            }
376        } else if(sortOrder == null) {
377            update = false;
378        }
379        
380        if(update) {
381            this.sortOrder = sortOrder;
382            sortOrderHasBeenModified = true;
383            clearHashAndString();
384        }
385    }
386    
387    public boolean getSortOrderHasBeenModified() {
388        return sortOrderHasBeenModified;
389    }
390    
391    public Long getFromTime() {
392        return fromTime;
393    }
394    
395    public void setFromTime(Long fromTime)
396            throws PersistenceNotNullException {
397        checkForNull(fromTime);
398        
399        boolean update = true;
400        
401        if(this.fromTime != null) {
402            if(this.fromTime.equals(fromTime)) {
403                update = false;
404            }
405        } else if(fromTime == null) {
406            update = false;
407        }
408        
409        if(update) {
410            this.fromTime = fromTime;
411            fromTimeHasBeenModified = true;
412            clearHashAndString();
413        }
414    }
415    
416    public boolean getFromTimeHasBeenModified() {
417        return fromTimeHasBeenModified;
418    }
419    
420    public Long getThruTime() {
421        return thruTime;
422    }
423    
424    public void setThruTime(Long thruTime)
425            throws PersistenceNotNullException {
426        checkForNull(thruTime);
427        
428        boolean update = true;
429        
430        if(this.thruTime != null) {
431            if(this.thruTime.equals(thruTime)) {
432                update = false;
433            }
434        } else if(thruTime == null) {
435            update = false;
436        }
437        
438        if(update) {
439            this.thruTime = thruTime;
440            thruTimeHasBeenModified = true;
441            clearHashAndString();
442        }
443    }
444    
445    public boolean getThruTimeHasBeenModified() {
446        return thruTimeHasBeenModified;
447    }
448    
449}