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 * PartyCreditLimitValue.java 021 */ 022 023package com.echothree.model.data.term.server.value; 024 025import com.echothree.model.data.term.common.pk.PartyCreditLimitPK; 026 027import com.echothree.model.data.term.server.factory.PartyCreditLimitFactory; 028 029import com.echothree.model.data.party.common.pk.PartyPK; 030import com.echothree.model.data.accounting.common.pk.CurrencyPK; 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 PartyCreditLimitValue 040 extends BaseValue<PartyCreditLimitPK> 041 implements Cloneable, Serializable { 042 043 private PartyPK partyPK; 044 private boolean partyPKHasBeenModified = false; 045 private CurrencyPK currencyPK; 046 private boolean currencyPKHasBeenModified = false; 047 private Long creditLimit; 048 private boolean creditLimitHasBeenModified = false; 049 private Long potentialCreditLimit; 050 private boolean potentialCreditLimitHasBeenModified = false; 051 private Long fromTime; 052 private boolean fromTimeHasBeenModified = false; 053 private Long thruTime; 054 private boolean thruTimeHasBeenModified = false; 055 056 private transient Integer _hashCode = null; 057 private transient String _stringValue = null; 058 059 private void constructFields(PartyPK partyPK, CurrencyPK currencyPK, Long creditLimit, Long potentialCreditLimit, Long fromTime, Long thruTime) 060 throws PersistenceNotNullException { 061 checkForNull(partyPK); 062 this.partyPK = partyPK; 063 checkForNull(currencyPK); 064 this.currencyPK = currencyPK; 065 this.creditLimit = creditLimit; 066 this.potentialCreditLimit = potentialCreditLimit; 067 checkForNull(fromTime); 068 this.fromTime = fromTime; 069 checkForNull(thruTime); 070 this.thruTime = thruTime; 071 } 072 073 /** Creates a new instance of PartyCreditLimitValue */ 074 public PartyCreditLimitValue(PartyCreditLimitPK partyCreditLimitPK, PartyPK partyPK, CurrencyPK currencyPK, Long creditLimit, Long potentialCreditLimit, Long fromTime, Long thruTime) 075 throws PersistenceNotNullException { 076 super(partyCreditLimitPK); 077 constructFields(partyPK, currencyPK, creditLimit, potentialCreditLimit, fromTime, thruTime); 078 } 079 080 /** Creates a new instance of PartyCreditLimitValue */ 081 public PartyCreditLimitValue(PartyPK partyPK, CurrencyPK currencyPK, Long creditLimit, Long potentialCreditLimit, Long fromTime, Long thruTime) 082 throws PersistenceNotNullException { 083 super(); 084 constructFields(partyPK, currencyPK, creditLimit, potentialCreditLimit, fromTime, thruTime); 085 } 086 087 @Override 088 public PartyCreditLimitFactory getBaseFactoryInstance() { 089 return PartyCreditLimitFactory.getInstance(); 090 } 091 092 @Override 093 public PartyCreditLimitValue clone() { 094 Object result; 095 096 try { 097 result = super.clone(); 098 } catch (CloneNotSupportedException cnse) { 099 // This shouldn't happen, fail when it does. 100 throw new PersistenceCloneException(cnse); 101 } 102 103 return (PartyCreditLimitValue)result; 104 } 105 106 @Override 107 public PartyCreditLimitPK getPrimaryKey() { 108 if(_primaryKey == null) { 109 _primaryKey = new PartyCreditLimitPK(entityId); 110 } 111 112 return _primaryKey; 113 } 114 115 private void clearHashAndString() { 116 _hashCode = null; 117 _stringValue = null; 118 } 119 120 @Override 121 public int hashCode() { 122 if(_hashCode == null) { 123 int hashCode = 17; 124 125 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 126 127 hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0); 128 hashCode = 37 * hashCode + ((currencyPK != null) ? currencyPK.hashCode() : 0); 129 hashCode = 37 * hashCode + ((creditLimit != null) ? creditLimit.hashCode() : 0); 130 hashCode = 37 * hashCode + ((potentialCreditLimit != null) ? potentialCreditLimit.hashCode() : 0); 131 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 132 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 133 134 _hashCode = hashCode; 135 } 136 137 return _hashCode; 138 } 139 140 @Override 141 public String toString() { 142 if(_stringValue == null) { 143 _stringValue = "{" + 144 "entityId=" + getEntityId() + 145 ", partyPK=" + getPartyPK() + 146 ", currencyPK=" + getCurrencyPK() + 147 ", creditLimit=" + getCreditLimit() + 148 ", potentialCreditLimit=" + getPotentialCreditLimit() + 149 ", fromTime=" + getFromTime() + 150 ", thruTime=" + getThruTime() + 151 "}"; 152 } 153 return _stringValue; 154 } 155 156 @Override 157 public boolean equals(Object other) { 158 if(this == other) 159 return true; 160 161 if(!hasIdentity()) 162 return false; 163 164 if(other instanceof PartyCreditLimitValue that) { 165 if(!that.hasIdentity()) 166 return false; 167 168 Long thisEntityId = getEntityId(); 169 Long thatEntityId = that.getEntityId(); 170 171 boolean objectsEqual = thisEntityId.equals(thatEntityId); 172 if(objectsEqual) 173 objectsEqual = isIdentical(that); 174 175 return objectsEqual; 176 } else { 177 return false; 178 } 179 } 180 181 public boolean isIdentical(Object other) { 182 if(other instanceof PartyCreditLimitValue that) { 183 boolean objectsEqual = true; 184 185 186 if(objectsEqual) { 187 PartyPK thisPartyPK = getPartyPK(); 188 PartyPK thatPartyPK = that.getPartyPK(); 189 190 if(thisPartyPK == null) { 191 objectsEqual = objectsEqual && (thatPartyPK == null); 192 } else { 193 objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK); 194 } 195 } 196 197 if(objectsEqual) { 198 CurrencyPK thisCurrencyPK = getCurrencyPK(); 199 CurrencyPK thatCurrencyPK = that.getCurrencyPK(); 200 201 if(thisCurrencyPK == null) { 202 objectsEqual = objectsEqual && (thatCurrencyPK == null); 203 } else { 204 objectsEqual = objectsEqual && thisCurrencyPK.equals(thatCurrencyPK); 205 } 206 } 207 208 if(objectsEqual) { 209 Long thisCreditLimit = getCreditLimit(); 210 Long thatCreditLimit = that.getCreditLimit(); 211 212 if(thisCreditLimit == null) { 213 objectsEqual = objectsEqual && (thatCreditLimit == null); 214 } else { 215 objectsEqual = objectsEqual && thisCreditLimit.equals(thatCreditLimit); 216 } 217 } 218 219 if(objectsEqual) { 220 Long thisPotentialCreditLimit = getPotentialCreditLimit(); 221 Long thatPotentialCreditLimit = that.getPotentialCreditLimit(); 222 223 if(thisPotentialCreditLimit == null) { 224 objectsEqual = objectsEqual && (thatPotentialCreditLimit == null); 225 } else { 226 objectsEqual = objectsEqual && thisPotentialCreditLimit.equals(thatPotentialCreditLimit); 227 } 228 } 229 230 if(objectsEqual) { 231 Long thisFromTime = getFromTime(); 232 Long thatFromTime = that.getFromTime(); 233 234 if(thisFromTime == null) { 235 objectsEqual = objectsEqual && (thatFromTime == null); 236 } else { 237 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 238 } 239 } 240 241 if(objectsEqual) { 242 Long thisThruTime = getThruTime(); 243 Long thatThruTime = that.getThruTime(); 244 245 if(thisThruTime == null) { 246 objectsEqual = objectsEqual && (thatThruTime == null); 247 } else { 248 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 249 } 250 } 251 252 return objectsEqual; 253 } else { 254 return false; 255 } 256 } 257 258 @Override 259 public boolean hasBeenModified() { 260 return partyPKHasBeenModified || currencyPKHasBeenModified || creditLimitHasBeenModified || potentialCreditLimitHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 261 } 262 263 @Override 264 public void clearHasBeenModified() { 265 partyPKHasBeenModified = false; 266 currencyPKHasBeenModified = false; 267 creditLimitHasBeenModified = false; 268 potentialCreditLimitHasBeenModified = false; 269 fromTimeHasBeenModified = false; 270 thruTimeHasBeenModified = false; 271 } 272 273 public PartyPK getPartyPK() { 274 return partyPK; 275 } 276 277 public void setPartyPK(PartyPK partyPK) 278 throws PersistenceNotNullException { 279 checkForNull(partyPK); 280 281 boolean update = true; 282 283 if(this.partyPK != null) { 284 if(this.partyPK.equals(partyPK)) { 285 update = false; 286 } 287 } else if(partyPK == null) { 288 update = false; 289 } 290 291 if(update) { 292 this.partyPK = partyPK; 293 partyPKHasBeenModified = true; 294 clearHashAndString(); 295 } 296 } 297 298 public boolean getPartyPKHasBeenModified() { 299 return partyPKHasBeenModified; 300 } 301 302 public CurrencyPK getCurrencyPK() { 303 return currencyPK; 304 } 305 306 public void setCurrencyPK(CurrencyPK currencyPK) 307 throws PersistenceNotNullException { 308 checkForNull(currencyPK); 309 310 boolean update = true; 311 312 if(this.currencyPK != null) { 313 if(this.currencyPK.equals(currencyPK)) { 314 update = false; 315 } 316 } else if(currencyPK == null) { 317 update = false; 318 } 319 320 if(update) { 321 this.currencyPK = currencyPK; 322 currencyPKHasBeenModified = true; 323 clearHashAndString(); 324 } 325 } 326 327 public boolean getCurrencyPKHasBeenModified() { 328 return currencyPKHasBeenModified; 329 } 330 331 public Long getCreditLimit() { 332 return creditLimit; 333 } 334 335 public void setCreditLimit(Long creditLimit) { 336 boolean update = true; 337 338 if(this.creditLimit != null) { 339 if(this.creditLimit.equals(creditLimit)) { 340 update = false; 341 } 342 } else if(creditLimit == null) { 343 update = false; 344 } 345 346 if(update) { 347 this.creditLimit = creditLimit; 348 creditLimitHasBeenModified = true; 349 clearHashAndString(); 350 } 351 } 352 353 public boolean getCreditLimitHasBeenModified() { 354 return creditLimitHasBeenModified; 355 } 356 357 public Long getPotentialCreditLimit() { 358 return potentialCreditLimit; 359 } 360 361 public void setPotentialCreditLimit(Long potentialCreditLimit) { 362 boolean update = true; 363 364 if(this.potentialCreditLimit != null) { 365 if(this.potentialCreditLimit.equals(potentialCreditLimit)) { 366 update = false; 367 } 368 } else if(potentialCreditLimit == null) { 369 update = false; 370 } 371 372 if(update) { 373 this.potentialCreditLimit = potentialCreditLimit; 374 potentialCreditLimitHasBeenModified = true; 375 clearHashAndString(); 376 } 377 } 378 379 public boolean getPotentialCreditLimitHasBeenModified() { 380 return potentialCreditLimitHasBeenModified; 381 } 382 383 public Long getFromTime() { 384 return fromTime; 385 } 386 387 public void setFromTime(Long fromTime) 388 throws PersistenceNotNullException { 389 checkForNull(fromTime); 390 391 boolean update = true; 392 393 if(this.fromTime != null) { 394 if(this.fromTime.equals(fromTime)) { 395 update = false; 396 } 397 } else if(fromTime == null) { 398 update = false; 399 } 400 401 if(update) { 402 this.fromTime = fromTime; 403 fromTimeHasBeenModified = true; 404 clearHashAndString(); 405 } 406 } 407 408 public boolean getFromTimeHasBeenModified() { 409 return fromTimeHasBeenModified; 410 } 411 412 public Long getThruTime() { 413 return thruTime; 414 } 415 416 public void setThruTime(Long thruTime) 417 throws PersistenceNotNullException { 418 checkForNull(thruTime); 419 420 boolean update = true; 421 422 if(this.thruTime != null) { 423 if(this.thruTime.equals(thruTime)) { 424 update = false; 425 } 426 } else if(thruTime == null) { 427 update = false; 428 } 429 430 if(update) { 431 this.thruTime = thruTime; 432 thruTimeHasBeenModified = true; 433 clearHashAndString(); 434 } 435 } 436 437 public boolean getThruTimeHasBeenModified() { 438 return thruTimeHasBeenModified; 439 } 440 441}