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 * LanguageValue.java
021 */
022
023package com.echothree.model.data.party.server.value;
024
025import com.echothree.model.data.party.common.pk.LanguagePK;
026
027import com.echothree.model.data.party.server.factory.LanguageFactory;
028
029import com.echothree.util.common.exception.PersistenceCloneException;
030import com.echothree.util.common.exception.PersistenceNotNullException;
031
032import com.echothree.util.server.persistence.BaseValue;
033
034import java.io.Serializable;
035
036public class LanguageValue
037        extends BaseValue<LanguagePK>
038        implements Cloneable, Serializable {
039    
040    private String languageIsoName;
041    private boolean languageIsoNameHasBeenModified = false;
042    private Boolean isDefault;
043    private boolean isDefaultHasBeenModified = false;
044    private Integer sortOrder;
045    private boolean sortOrderHasBeenModified = false;
046    
047    private transient Integer _hashCode = null;
048    private transient String _stringValue = null;
049    
050    private void constructFields(String languageIsoName, Boolean isDefault, Integer sortOrder)
051            throws PersistenceNotNullException {
052        checkForNull(languageIsoName);
053        this.languageIsoName = languageIsoName;
054        checkForNull(isDefault);
055        this.isDefault = isDefault;
056        checkForNull(sortOrder);
057        this.sortOrder = sortOrder;
058    }
059    
060    /** Creates a new instance of LanguageValue */
061    public LanguageValue(LanguagePK languagePK, String languageIsoName, Boolean isDefault, Integer sortOrder)
062            throws PersistenceNotNullException {
063        super(languagePK);
064        constructFields(languageIsoName, isDefault, sortOrder);
065    }
066    
067    /** Creates a new instance of LanguageValue */
068    public LanguageValue(String languageIsoName, Boolean isDefault, Integer sortOrder)
069            throws PersistenceNotNullException {
070        super();
071        constructFields(languageIsoName, isDefault, sortOrder);
072    }
073    
074   @Override
075   public LanguageFactory getBaseFactoryInstance() {
076        return LanguageFactory.getInstance();
077    }
078    
079    @Override
080    public LanguageValue clone() {
081        Object result;
082        
083        try {
084            result = super.clone();
085        } catch (CloneNotSupportedException cnse) {
086            // This shouldn't happen, fail when it does.
087            throw new PersistenceCloneException(cnse);
088        }
089        
090        return (LanguageValue)result;
091    }
092    
093   @Override
094    public LanguagePK getPrimaryKey() {
095        if(_primaryKey == null) {
096            _primaryKey = new LanguagePK(entityId);
097        }
098        
099        return _primaryKey;
100    }
101    
102    private void clearHashAndString() {
103        _hashCode = null;
104        _stringValue = null;
105    }
106    
107    @Override
108    public int hashCode() {
109        if(_hashCode == null) {
110            int hashCode = 17;
111            
112            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
113            
114            hashCode = 37 * hashCode + ((languageIsoName != null) ? languageIsoName.hashCode() : 0);
115            hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0);
116            hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0);
117            
118            _hashCode = hashCode;
119        }
120        
121        return _hashCode;
122    }
123    
124    @Override
125    public String toString() {
126        if(_stringValue == null) {
127            _stringValue = "{" + 
128                    "entityId=" + getEntityId() +
129                    ", languageIsoName=" + getLanguageIsoName() +
130                    ", isDefault=" + getIsDefault() +
131                    ", sortOrder=" + getSortOrder() +
132                    "}";
133        }
134        return _stringValue;
135    }
136    
137    @Override
138    public boolean equals(Object other) {
139        if(this == other)
140            return true;
141        
142        if(!hasIdentity())
143            return false;
144        
145        if(other instanceof  LanguageValue that) {
146            if(!that.hasIdentity())
147                return false;
148            
149            Long thisEntityId = getEntityId();
150            Long thatEntityId = that.getEntityId();
151            
152            boolean objectsEqual = thisEntityId.equals(thatEntityId);
153            if(objectsEqual)
154                objectsEqual = isIdentical(that);
155            
156            return objectsEqual;
157        } else {
158            return false;
159        }
160    }
161    
162    public boolean isIdentical(Object other) {
163        if(other instanceof LanguageValue that) {
164            boolean objectsEqual = true;
165            
166            
167            if(objectsEqual) {
168                String thisLanguageIsoName = getLanguageIsoName();
169                String thatLanguageIsoName = that.getLanguageIsoName();
170                
171                if(thisLanguageIsoName == null) {
172                    objectsEqual = objectsEqual && (thatLanguageIsoName == null);
173                } else {
174                    objectsEqual = objectsEqual && thisLanguageIsoName.equals(thatLanguageIsoName);
175                }
176            }
177            
178            if(objectsEqual) {
179                Boolean thisIsDefault = getIsDefault();
180                Boolean thatIsDefault = that.getIsDefault();
181                
182                if(thisIsDefault == null) {
183                    objectsEqual = objectsEqual && (thatIsDefault == null);
184                } else {
185                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
186                }
187            }
188            
189            if(objectsEqual) {
190                Integer thisSortOrder = getSortOrder();
191                Integer thatSortOrder = that.getSortOrder();
192                
193                if(thisSortOrder == null) {
194                    objectsEqual = objectsEqual && (thatSortOrder == null);
195                } else {
196                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
197                }
198            }
199            
200            return objectsEqual;
201        } else {
202            return false;
203        }
204    }
205    
206    @Override
207    public boolean hasBeenModified() {
208        return languageIsoNameHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified;
209    }
210    
211    @Override
212    public void clearHasBeenModified() {
213        languageIsoNameHasBeenModified = false;
214        isDefaultHasBeenModified = false;
215        sortOrderHasBeenModified = false;
216    }
217    
218    public String getLanguageIsoName() {
219        return languageIsoName;
220    }
221    
222    public void setLanguageIsoName(String languageIsoName)
223            throws PersistenceNotNullException {
224        checkForNull(languageIsoName);
225        
226        boolean update = true;
227        
228        if(this.languageIsoName != null) {
229            if(this.languageIsoName.equals(languageIsoName)) {
230                update = false;
231            }
232        } else if(languageIsoName == null) {
233            update = false;
234        }
235        
236        if(update) {
237            this.languageIsoName = languageIsoName;
238            languageIsoNameHasBeenModified = true;
239            clearHashAndString();
240        }
241    }
242    
243    public boolean getLanguageIsoNameHasBeenModified() {
244        return languageIsoNameHasBeenModified;
245    }
246    
247    public Boolean getIsDefault() {
248        return isDefault;
249    }
250    
251    public void setIsDefault(Boolean isDefault)
252            throws PersistenceNotNullException {
253        checkForNull(isDefault);
254        
255        boolean update = true;
256        
257        if(this.isDefault != null) {
258            if(this.isDefault.equals(isDefault)) {
259                update = false;
260            }
261        } else if(isDefault == null) {
262            update = false;
263        }
264        
265        if(update) {
266            this.isDefault = isDefault;
267            isDefaultHasBeenModified = true;
268            clearHashAndString();
269        }
270    }
271    
272    public boolean getIsDefaultHasBeenModified() {
273        return isDefaultHasBeenModified;
274    }
275    
276    public Integer getSortOrder() {
277        return sortOrder;
278    }
279    
280    public void setSortOrder(Integer sortOrder)
281            throws PersistenceNotNullException {
282        checkForNull(sortOrder);
283        
284        boolean update = true;
285        
286        if(this.sortOrder != null) {
287            if(this.sortOrder.equals(sortOrder)) {
288                update = false;
289            }
290        } else if(sortOrder == null) {
291            update = false;
292        }
293        
294        if(update) {
295            this.sortOrder = sortOrder;
296            sortOrderHasBeenModified = true;
297            clearHashAndString();
298        }
299    }
300    
301    public boolean getSortOrderHasBeenModified() {
302        return sortOrderHasBeenModified;
303    }
304    
305}