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