001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 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 036import javax.annotation.Nonnull; 037import javax.annotation.Nullable; 038 039public class LanguageValue 040 extends BaseValue<LanguagePK> 041 implements Cloneable, Serializable { 042 043 private String languageIsoName; 044 private boolean languageIsoNameHasBeenModified = false; 045 private Boolean isDefault; 046 private boolean isDefaultHasBeenModified = false; 047 private Integer sortOrder; 048 private boolean sortOrderHasBeenModified = false; 049 050 private transient Integer _hashCode = null; 051 private transient String _stringValue = null; 052 053 private void constructFields(String languageIsoName, Boolean isDefault, Integer sortOrder) 054 throws PersistenceNotNullException { 055 checkForNull(languageIsoName); 056 this.languageIsoName = languageIsoName; 057 checkForNull(isDefault); 058 this.isDefault = isDefault; 059 checkForNull(sortOrder); 060 this.sortOrder = sortOrder; 061 } 062 063 /** Creates a new instance of LanguageValue */ 064 public LanguageValue(LanguagePK languagePK, String languageIsoName, Boolean isDefault, Integer sortOrder) 065 throws PersistenceNotNullException { 066 super(languagePK); 067 constructFields(languageIsoName, isDefault, sortOrder); 068 } 069 070 /** Creates a new instance of LanguageValue */ 071 public LanguageValue(String languageIsoName, Boolean isDefault, Integer sortOrder) 072 throws PersistenceNotNullException { 073 super(); 074 constructFields(languageIsoName, isDefault, sortOrder); 075 } 076 077 @Override 078 @Nonnull 079 public LanguageFactory getBaseFactoryInstance() { 080 return LanguageFactory.getInstance(); 081 } 082 083 @Override 084 @Nonnull 085 public LanguageValue clone() { 086 Object result; 087 088 try { 089 result = super.clone(); 090 } catch (CloneNotSupportedException cnse) { 091 // This shouldn't happen, fail when it does. 092 throw new PersistenceCloneException(cnse); 093 } 094 095 return (LanguageValue)result; 096 } 097 098 @Override 099 @Nonnull 100 public LanguagePK getPrimaryKey() { 101 if(_primaryKey == null) { 102 _primaryKey = new LanguagePK(entityId); 103 } 104 105 return _primaryKey; 106 } 107 108 private void clearHashAndString() { 109 _hashCode = null; 110 _stringValue = null; 111 } 112 113 @Override 114 public int hashCode() { 115 if(_hashCode == null) { 116 int hashCode = 17; 117 118 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 119 120 hashCode = 37 * hashCode + ((languageIsoName != null) ? languageIsoName.hashCode() : 0); 121 hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0); 122 hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0); 123 124 _hashCode = hashCode; 125 } 126 127 return _hashCode; 128 } 129 130 @Override 131 @Nonnull 132 public String toString() { 133 if(_stringValue == null) { 134 _stringValue = "{" + 135 "entityId=" + getEntityId() + 136 ", languageIsoName=" + getLanguageIsoName() + 137 ", isDefault=" + getIsDefault() + 138 ", sortOrder=" + getSortOrder() + 139 "}"; 140 } 141 return _stringValue; 142 } 143 144 @Override 145 public boolean equals(Object other) { 146 if(this == other) 147 return true; 148 149 if(!hasIdentity()) 150 return false; 151 152 if(other instanceof LanguageValue that) { 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 = 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 that) { 171 boolean objectsEqual = true; 172 173 174 if(objectsEqual) { 175 String thisLanguageIsoName = getLanguageIsoName(); 176 String thatLanguageIsoName = that.getLanguageIsoName(); 177 178 if(thisLanguageIsoName == null) { 179 objectsEqual = objectsEqual && (thatLanguageIsoName == null); 180 } else { 181 objectsEqual = objectsEqual && thisLanguageIsoName.equals(thatLanguageIsoName); 182 } 183 } 184 185 if(objectsEqual) { 186 Boolean thisIsDefault = getIsDefault(); 187 Boolean thatIsDefault = that.getIsDefault(); 188 189 if(thisIsDefault == null) { 190 objectsEqual = objectsEqual && (thatIsDefault == null); 191 } else { 192 objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault); 193 } 194 } 195 196 if(objectsEqual) { 197 Integer thisSortOrder = getSortOrder(); 198 Integer thatSortOrder = that.getSortOrder(); 199 200 if(thisSortOrder == null) { 201 objectsEqual = objectsEqual && (thatSortOrder == null); 202 } else { 203 objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder); 204 } 205 } 206 207 return objectsEqual; 208 } else { 209 return false; 210 } 211 } 212 213 @Override 214 public boolean hasBeenModified() { 215 return languageIsoNameHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified; 216 } 217 218 @Override 219 public void clearHasBeenModified() { 220 languageIsoNameHasBeenModified = false; 221 isDefaultHasBeenModified = false; 222 sortOrderHasBeenModified = false; 223 } 224 225 @Nonnull 226 public String getLanguageIsoName() { 227 return languageIsoName; 228 } 229 230 public void setLanguageIsoName(@Nonnull 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 @Nonnull 256 public Boolean getIsDefault() { 257 return isDefault; 258 } 259 260 public void setIsDefault(@Nonnull Boolean isDefault) 261 throws PersistenceNotNullException { 262 checkForNull(isDefault); 263 264 boolean update = true; 265 266 if(this.isDefault != null) { 267 if(this.isDefault.equals(isDefault)) { 268 update = false; 269 } 270 } else if(isDefault == null) { 271 update = false; 272 } 273 274 if(update) { 275 this.isDefault = isDefault; 276 isDefaultHasBeenModified = true; 277 clearHashAndString(); 278 } 279 } 280 281 public boolean getIsDefaultHasBeenModified() { 282 return isDefaultHasBeenModified; 283 } 284 285 @Nonnull 286 public Integer getSortOrder() { 287 return sortOrder; 288 } 289 290 public void setSortOrder(@Nonnull Integer sortOrder) 291 throws PersistenceNotNullException { 292 checkForNull(sortOrder); 293 294 boolean update = true; 295 296 if(this.sortOrder != null) { 297 if(this.sortOrder.equals(sortOrder)) { 298 update = false; 299 } 300 } else if(sortOrder == null) { 301 update = false; 302 } 303 304 if(update) { 305 this.sortOrder = sortOrder; 306 sortOrderHasBeenModified = true; 307 clearHashAndString(); 308 } 309 } 310 311 public boolean getSortOrderHasBeenModified() { 312 return sortOrderHasBeenModified; 313 } 314 315}