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