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 * HarmonizedTariffScheduleCodeUnitDescriptionValue.java
021 */
022
023package com.echothree.model.data.item.server.value;
024
025import com.echothree.model.data.item.common.pk.HarmonizedTariffScheduleCodeUnitDescriptionPK;
026
027import com.echothree.model.data.item.server.factory.HarmonizedTariffScheduleCodeUnitDescriptionFactory;
028
029import com.echothree.model.data.item.common.pk.HarmonizedTariffScheduleCodeUnitPK;
030import com.echothree.model.data.party.common.pk.LanguagePK;
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 HarmonizedTariffScheduleCodeUnitDescriptionValue
040        extends BaseValue<HarmonizedTariffScheduleCodeUnitDescriptionPK>
041        implements Cloneable, Serializable {
042    
043    private HarmonizedTariffScheduleCodeUnitPK harmonizedTariffScheduleCodeUnitPK;
044    private boolean harmonizedTariffScheduleCodeUnitPKHasBeenModified = false;
045    private LanguagePK languagePK;
046    private boolean languagePKHasBeenModified = false;
047    private String description;
048    private boolean descriptionHasBeenModified = false;
049    private Long fromTime;
050    private boolean fromTimeHasBeenModified = false;
051    private Long thruTime;
052    private boolean thruTimeHasBeenModified = false;
053    
054    private transient Integer _hashCode = null;
055    private transient String _stringValue = null;
056    
057    private void constructFields(HarmonizedTariffScheduleCodeUnitPK harmonizedTariffScheduleCodeUnitPK, LanguagePK languagePK, String description, Long fromTime, Long thruTime)
058            throws PersistenceNotNullException {
059        checkForNull(harmonizedTariffScheduleCodeUnitPK);
060        this.harmonizedTariffScheduleCodeUnitPK = harmonizedTariffScheduleCodeUnitPK;
061        checkForNull(languagePK);
062        this.languagePK = languagePK;
063        this.description = description;
064        checkForNull(fromTime);
065        this.fromTime = fromTime;
066        checkForNull(thruTime);
067        this.thruTime = thruTime;
068    }
069    
070    /** Creates a new instance of HarmonizedTariffScheduleCodeUnitDescriptionValue */
071    public HarmonizedTariffScheduleCodeUnitDescriptionValue(HarmonizedTariffScheduleCodeUnitDescriptionPK harmonizedTariffScheduleCodeUnitDescriptionPK, HarmonizedTariffScheduleCodeUnitPK harmonizedTariffScheduleCodeUnitPK, LanguagePK languagePK, String description, Long fromTime, Long thruTime)
072            throws PersistenceNotNullException {
073        super(harmonizedTariffScheduleCodeUnitDescriptionPK);
074        constructFields(harmonizedTariffScheduleCodeUnitPK, languagePK, description, fromTime, thruTime);
075    }
076    
077    /** Creates a new instance of HarmonizedTariffScheduleCodeUnitDescriptionValue */
078    public HarmonizedTariffScheduleCodeUnitDescriptionValue(HarmonizedTariffScheduleCodeUnitPK harmonizedTariffScheduleCodeUnitPK, LanguagePK languagePK, String description, Long fromTime, Long thruTime)
079            throws PersistenceNotNullException {
080        super();
081        constructFields(harmonizedTariffScheduleCodeUnitPK, languagePK, description, fromTime, thruTime);
082    }
083    
084   @Override
085   public HarmonizedTariffScheduleCodeUnitDescriptionFactory getBaseFactoryInstance() {
086        return HarmonizedTariffScheduleCodeUnitDescriptionFactory.getInstance();
087    }
088    
089    @Override
090    public HarmonizedTariffScheduleCodeUnitDescriptionValue 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 (HarmonizedTariffScheduleCodeUnitDescriptionValue)result;
101    }
102    
103   @Override
104    public HarmonizedTariffScheduleCodeUnitDescriptionPK getPrimaryKey() {
105        if(_primaryKey == null) {
106            _primaryKey = new HarmonizedTariffScheduleCodeUnitDescriptionPK(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 + ((harmonizedTariffScheduleCodeUnitPK != null) ? harmonizedTariffScheduleCodeUnitPK.hashCode() : 0);
125            hashCode = 37 * hashCode + ((languagePK != null) ? languagePK.hashCode() : 0);
126            hashCode = 37 * hashCode + ((description != null) ? description.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            _stringValue = "{" + 
140                    "entityId=" + getEntityId() +
141                    ", harmonizedTariffScheduleCodeUnitPK=" + getHarmonizedTariffScheduleCodeUnitPK() +
142                    ", languagePK=" + getLanguagePK() +
143                    ", description=" + getDescription() +
144                    ", fromTime=" + getFromTime() +
145                    ", thruTime=" + getThruTime() +
146                    "}";
147        }
148        return _stringValue;
149    }
150    
151    @Override
152    public boolean equals(Object other) {
153        if(this == other)
154            return true;
155        
156        if(!hasIdentity())
157            return false;
158        
159        if(other instanceof  HarmonizedTariffScheduleCodeUnitDescriptionValue that) {
160            if(!that.hasIdentity())
161                return false;
162            
163            Long thisEntityId = getEntityId();
164            Long thatEntityId = that.getEntityId();
165            
166            boolean objectsEqual = thisEntityId.equals(thatEntityId);
167            if(objectsEqual)
168                objectsEqual = isIdentical(that);
169            
170            return objectsEqual;
171        } else {
172            return false;
173        }
174    }
175    
176    public boolean isIdentical(Object other) {
177        if(other instanceof HarmonizedTariffScheduleCodeUnitDescriptionValue that) {
178            boolean objectsEqual = true;
179            
180            
181            if(objectsEqual) {
182                HarmonizedTariffScheduleCodeUnitPK thisHarmonizedTariffScheduleCodeUnitPK = getHarmonizedTariffScheduleCodeUnitPK();
183                HarmonizedTariffScheduleCodeUnitPK thatHarmonizedTariffScheduleCodeUnitPK = that.getHarmonizedTariffScheduleCodeUnitPK();
184                
185                if(thisHarmonizedTariffScheduleCodeUnitPK == null) {
186                    objectsEqual = objectsEqual && (thatHarmonizedTariffScheduleCodeUnitPK == null);
187                } else {
188                    objectsEqual = objectsEqual && thisHarmonizedTariffScheduleCodeUnitPK.equals(thatHarmonizedTariffScheduleCodeUnitPK);
189                }
190            }
191            
192            if(objectsEqual) {
193                LanguagePK thisLanguagePK = getLanguagePK();
194                LanguagePK thatLanguagePK = that.getLanguagePK();
195                
196                if(thisLanguagePK == null) {
197                    objectsEqual = objectsEqual && (thatLanguagePK == null);
198                } else {
199                    objectsEqual = objectsEqual && thisLanguagePK.equals(thatLanguagePK);
200                }
201            }
202            
203            if(objectsEqual) {
204                String thisDescription = getDescription();
205                String thatDescription = that.getDescription();
206                
207                if(thisDescription == null) {
208                    objectsEqual = objectsEqual && (thatDescription == null);
209                } else {
210                    objectsEqual = objectsEqual && thisDescription.equals(thatDescription);
211                }
212            }
213            
214            if(objectsEqual) {
215                Long thisFromTime = getFromTime();
216                Long thatFromTime = that.getFromTime();
217                
218                if(thisFromTime == null) {
219                    objectsEqual = objectsEqual && (thatFromTime == null);
220                } else {
221                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
222                }
223            }
224            
225            if(objectsEqual) {
226                Long thisThruTime = getThruTime();
227                Long thatThruTime = that.getThruTime();
228                
229                if(thisThruTime == null) {
230                    objectsEqual = objectsEqual && (thatThruTime == null);
231                } else {
232                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
233                }
234            }
235            
236            return objectsEqual;
237        } else {
238            return false;
239        }
240    }
241    
242    @Override
243    public boolean hasBeenModified() {
244        return harmonizedTariffScheduleCodeUnitPKHasBeenModified || languagePKHasBeenModified || descriptionHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
245    }
246    
247    @Override
248    public void clearHasBeenModified() {
249        harmonizedTariffScheduleCodeUnitPKHasBeenModified = false;
250        languagePKHasBeenModified = false;
251        descriptionHasBeenModified = false;
252        fromTimeHasBeenModified = false;
253        thruTimeHasBeenModified = false;
254    }
255    
256    public HarmonizedTariffScheduleCodeUnitPK getHarmonizedTariffScheduleCodeUnitPK() {
257        return harmonizedTariffScheduleCodeUnitPK;
258    }
259    
260    public void setHarmonizedTariffScheduleCodeUnitPK(HarmonizedTariffScheduleCodeUnitPK harmonizedTariffScheduleCodeUnitPK)
261            throws PersistenceNotNullException {
262        checkForNull(harmonizedTariffScheduleCodeUnitPK);
263        
264        boolean update = true;
265        
266        if(this.harmonizedTariffScheduleCodeUnitPK != null) {
267            if(this.harmonizedTariffScheduleCodeUnitPK.equals(harmonizedTariffScheduleCodeUnitPK)) {
268                update = false;
269            }
270        } else if(harmonizedTariffScheduleCodeUnitPK == null) {
271            update = false;
272        }
273        
274        if(update) {
275            this.harmonizedTariffScheduleCodeUnitPK = harmonizedTariffScheduleCodeUnitPK;
276            harmonizedTariffScheduleCodeUnitPKHasBeenModified = true;
277            clearHashAndString();
278        }
279    }
280    
281    public boolean getHarmonizedTariffScheduleCodeUnitPKHasBeenModified() {
282        return harmonizedTariffScheduleCodeUnitPKHasBeenModified;
283    }
284    
285    public LanguagePK getLanguagePK() {
286        return languagePK;
287    }
288    
289    public void setLanguagePK(LanguagePK languagePK)
290            throws PersistenceNotNullException {
291        checkForNull(languagePK);
292        
293        boolean update = true;
294        
295        if(this.languagePK != null) {
296            if(this.languagePK.equals(languagePK)) {
297                update = false;
298            }
299        } else if(languagePK == null) {
300            update = false;
301        }
302        
303        if(update) {
304            this.languagePK = languagePK;
305            languagePKHasBeenModified = true;
306            clearHashAndString();
307        }
308    }
309    
310    public boolean getLanguagePKHasBeenModified() {
311        return languagePKHasBeenModified;
312    }
313    
314    public String getDescription() {
315        return description;
316    }
317    
318    public void setDescription(String description) {
319        boolean update = true;
320        
321        if(this.description != null) {
322            if(this.description.equals(description)) {
323                update = false;
324            }
325        } else if(description == null) {
326            update = false;
327        }
328        
329        if(update) {
330            this.description = description;
331            descriptionHasBeenModified = true;
332            clearHashAndString();
333        }
334    }
335    
336    public boolean getDescriptionHasBeenModified() {
337        return descriptionHasBeenModified;
338    }
339    
340    public Long getFromTime() {
341        return fromTime;
342    }
343    
344    public void setFromTime(Long fromTime)
345            throws PersistenceNotNullException {
346        checkForNull(fromTime);
347        
348        boolean update = true;
349        
350        if(this.fromTime != null) {
351            if(this.fromTime.equals(fromTime)) {
352                update = false;
353            }
354        } else if(fromTime == null) {
355            update = false;
356        }
357        
358        if(update) {
359            this.fromTime = fromTime;
360            fromTimeHasBeenModified = true;
361            clearHashAndString();
362        }
363    }
364    
365    public boolean getFromTimeHasBeenModified() {
366        return fromTimeHasBeenModified;
367    }
368    
369    public Long getThruTime() {
370        return thruTime;
371    }
372    
373    public void setThruTime(Long thruTime)
374            throws PersistenceNotNullException {
375        checkForNull(thruTime);
376        
377        boolean update = true;
378        
379        if(this.thruTime != null) {
380            if(this.thruTime.equals(thruTime)) {
381                update = false;
382            }
383        } else if(thruTime == null) {
384            update = false;
385        }
386        
387        if(update) {
388            this.thruTime = thruTime;
389            thruTimeHasBeenModified = true;
390            clearHashAndString();
391        }
392    }
393    
394    public boolean getThruTimeHasBeenModified() {
395        return thruTimeHasBeenModified;
396    }
397    
398}