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