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 * 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            StringBuilder stringValue = new StringBuilder("{");
128            
129            stringValue.append("entityId=").append(getEntityId());
130            
131            stringValue.append(", languageIsoName=").append(getLanguageIsoName());
132            stringValue.append(", isDefault=").append(getIsDefault());
133            stringValue.append(", sortOrder=").append(getSortOrder());
134            
135            stringValue.append('}');
136            
137            _stringValue = stringValue.toString();
138        }
139        return _stringValue;
140    }
141    
142    @Override
143    public boolean equals(Object other) {
144        if(this == other)
145            return true;
146        
147        if(!hasIdentity())
148            return false;
149        
150        if(other instanceof  LanguageValue) {
151            LanguageValue that = (LanguageValue)other;
152            
153            if(!that.hasIdentity())
154                return false;
155            
156            Long thisEntityId = getEntityId();
157            Long thatEntityId = that.getEntityId();
158            
159            boolean objectsEqual = thisEntityId.equals(thatEntityId);
160            if(objectsEqual)
161                objectsEqual = objectsEqual && isIdentical(that);
162            
163            return objectsEqual;
164        } else {
165            return false;
166        }
167    }
168    
169    public boolean isIdentical(Object other) {
170        if(other instanceof LanguageValue) {
171            LanguageValue that = (LanguageValue)other;
172            boolean objectsEqual = true;
173            
174            
175            if(objectsEqual) {
176                String thisLanguageIsoName = getLanguageIsoName();
177                String thatLanguageIsoName = that.getLanguageIsoName();
178                
179                if(thisLanguageIsoName == null) {
180                    objectsEqual = objectsEqual && (thatLanguageIsoName == null);
181                } else {
182                    objectsEqual = objectsEqual && thisLanguageIsoName.equals(thatLanguageIsoName);
183                }
184            }
185            
186            if(objectsEqual) {
187                Boolean thisIsDefault = getIsDefault();
188                Boolean thatIsDefault = that.getIsDefault();
189                
190                if(thisIsDefault == null) {
191                    objectsEqual = objectsEqual && (thatIsDefault == null);
192                } else {
193                    objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault);
194                }
195            }
196            
197            if(objectsEqual) {
198                Integer thisSortOrder = getSortOrder();
199                Integer thatSortOrder = that.getSortOrder();
200                
201                if(thisSortOrder == null) {
202                    objectsEqual = objectsEqual && (thatSortOrder == null);
203                } else {
204                    objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder);
205                }
206            }
207            
208            return objectsEqual;
209        } else {
210            return false;
211        }
212    }
213    
214    @Override
215    public boolean hasBeenModified() {
216        return languageIsoNameHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified;
217    }
218    
219    @Override
220    public void clearHasBeenModified() {
221        languageIsoNameHasBeenModified = false;
222        isDefaultHasBeenModified = false;
223        sortOrderHasBeenModified = false;
224    }
225    
226    public String getLanguageIsoName() {
227        return languageIsoName;
228    }
229    
230    public void setLanguageIsoName(String languageIsoName)
231            throws PersistenceNotNullException {
232        checkForNull(languageIsoName);
233        
234        boolean update = true;
235        
236        if(this.languageIsoName != null) {
237            if(this.languageIsoName.equals(languageIsoName)) {
238                update = false;
239            }
240        } else if(languageIsoName == null) {
241            update = false;
242        }
243        
244        if(update) {
245            this.languageIsoName = languageIsoName;
246            languageIsoNameHasBeenModified = true;
247            clearHashAndString();
248        }
249    }
250    
251    public boolean getLanguageIsoNameHasBeenModified() {
252        return languageIsoNameHasBeenModified;
253    }
254    
255    public Boolean getIsDefault() {
256        return isDefault;
257    }
258    
259    public void setIsDefault(Boolean isDefault)
260            throws PersistenceNotNullException {
261        checkForNull(isDefault);
262        
263        boolean update = true;
264        
265        if(this.isDefault != null) {
266            if(this.isDefault.equals(isDefault)) {
267                update = false;
268            }
269        } else if(isDefault == null) {
270            update = false;
271        }
272        
273        if(update) {
274            this.isDefault = isDefault;
275            isDefaultHasBeenModified = true;
276            clearHashAndString();
277        }
278    }
279    
280    public boolean getIsDefaultHasBeenModified() {
281        return isDefaultHasBeenModified;
282    }
283    
284    public Integer getSortOrder() {
285        return sortOrder;
286    }
287    
288    public void setSortOrder(Integer sortOrder)
289            throws PersistenceNotNullException {
290        checkForNull(sortOrder);
291        
292        boolean update = true;
293        
294        if(this.sortOrder != null) {
295            if(this.sortOrder.equals(sortOrder)) {
296                update = false;
297            }
298        } else if(sortOrder == null) {
299            update = false;
300        }
301        
302        if(update) {
303            this.sortOrder = sortOrder;
304            sortOrderHasBeenModified = true;
305            clearHashAndString();
306        }
307    }
308    
309    public boolean getSortOrderHasBeenModified() {
310        return sortOrderHasBeenModified;
311    }
312    
313}