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 * DateDrivenTermValue.java 021 */ 022 023package com.echothree.model.data.term.server.value; 024 025import com.echothree.model.data.term.common.pk.DateDrivenTermPK; 026 027import com.echothree.model.data.term.server.factory.DateDrivenTermFactory; 028 029import com.echothree.model.data.term.common.pk.TermPK; 030 031import com.echothree.util.common.exception.PersistenceCloneException; 032import com.echothree.util.common.exception.PersistenceNotNullException; 033 034import com.echothree.util.server.persistence.BaseValue; 035 036import java.io.Serializable; 037 038public class DateDrivenTermValue 039 extends BaseValue<DateDrivenTermPK> 040 implements Cloneable, Serializable { 041 042 private TermPK termPK; 043 private boolean termPKHasBeenModified = false; 044 private Integer netDueDayOfMonth; 045 private boolean netDueDayOfMonthHasBeenModified = false; 046 private Integer dueNextMonthDays; 047 private boolean dueNextMonthDaysHasBeenModified = false; 048 private Integer discountPercentage; 049 private boolean discountPercentageHasBeenModified = false; 050 private Integer discountBeforeDayOfMonth; 051 private boolean discountBeforeDayOfMonthHasBeenModified = false; 052 private Long fromTime; 053 private boolean fromTimeHasBeenModified = false; 054 private Long thruTime; 055 private boolean thruTimeHasBeenModified = false; 056 057 private transient Integer _hashCode = null; 058 private transient String _stringValue = null; 059 060 private void constructFields(TermPK termPK, Integer netDueDayOfMonth, Integer dueNextMonthDays, Integer discountPercentage, Integer discountBeforeDayOfMonth, Long fromTime, Long thruTime) 061 throws PersistenceNotNullException { 062 checkForNull(termPK); 063 this.termPK = termPK; 064 checkForNull(netDueDayOfMonth); 065 this.netDueDayOfMonth = netDueDayOfMonth; 066 checkForNull(dueNextMonthDays); 067 this.dueNextMonthDays = dueNextMonthDays; 068 checkForNull(discountPercentage); 069 this.discountPercentage = discountPercentage; 070 checkForNull(discountBeforeDayOfMonth); 071 this.discountBeforeDayOfMonth = discountBeforeDayOfMonth; 072 checkForNull(fromTime); 073 this.fromTime = fromTime; 074 checkForNull(thruTime); 075 this.thruTime = thruTime; 076 } 077 078 /** Creates a new instance of DateDrivenTermValue */ 079 public DateDrivenTermValue(DateDrivenTermPK dateDrivenTermPK, TermPK termPK, Integer netDueDayOfMonth, Integer dueNextMonthDays, Integer discountPercentage, Integer discountBeforeDayOfMonth, Long fromTime, Long thruTime) 080 throws PersistenceNotNullException { 081 super(dateDrivenTermPK); 082 constructFields(termPK, netDueDayOfMonth, dueNextMonthDays, discountPercentage, discountBeforeDayOfMonth, fromTime, thruTime); 083 } 084 085 /** Creates a new instance of DateDrivenTermValue */ 086 public DateDrivenTermValue(TermPK termPK, Integer netDueDayOfMonth, Integer dueNextMonthDays, Integer discountPercentage, Integer discountBeforeDayOfMonth, Long fromTime, Long thruTime) 087 throws PersistenceNotNullException { 088 super(); 089 constructFields(termPK, netDueDayOfMonth, dueNextMonthDays, discountPercentage, discountBeforeDayOfMonth, fromTime, thruTime); 090 } 091 092 @Override 093 public DateDrivenTermFactory getBaseFactoryInstance() { 094 return DateDrivenTermFactory.getInstance(); 095 } 096 097 @Override 098 public DateDrivenTermValue 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 (DateDrivenTermValue)result; 109 } 110 111 @Override 112 public DateDrivenTermPK getPrimaryKey() { 113 if(_primaryKey == null) { 114 _primaryKey = new DateDrivenTermPK(entityId); 115 } 116 117 return _primaryKey; 118 } 119 120 private void clearHashAndString() { 121 _hashCode = null; 122 _stringValue = null; 123 } 124 125 @Override 126 public int hashCode() { 127 if(_hashCode == null) { 128 int hashCode = 17; 129 130 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 131 132 hashCode = 37 * hashCode + ((termPK != null) ? termPK.hashCode() : 0); 133 hashCode = 37 * hashCode + ((netDueDayOfMonth != null) ? netDueDayOfMonth.hashCode() : 0); 134 hashCode = 37 * hashCode + ((dueNextMonthDays != null) ? dueNextMonthDays.hashCode() : 0); 135 hashCode = 37 * hashCode + ((discountPercentage != null) ? discountPercentage.hashCode() : 0); 136 hashCode = 37 * hashCode + ((discountBeforeDayOfMonth != null) ? discountBeforeDayOfMonth.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 public String toString() { 148 if(_stringValue == null) { 149 StringBuilder stringValue = new StringBuilder("{"); 150 151 stringValue.append("entityId=").append(getEntityId()); 152 153 stringValue.append(", termPK=").append(getTermPK()); 154 stringValue.append(", netDueDayOfMonth=").append(getNetDueDayOfMonth()); 155 stringValue.append(", dueNextMonthDays=").append(getDueNextMonthDays()); 156 stringValue.append(", discountPercentage=").append(getDiscountPercentage()); 157 stringValue.append(", discountBeforeDayOfMonth=").append(getDiscountBeforeDayOfMonth()); 158 stringValue.append(", fromTime=").append(getFromTime()); 159 stringValue.append(", thruTime=").append(getThruTime()); 160 161 stringValue.append('}'); 162 163 _stringValue = stringValue.toString(); 164 } 165 return _stringValue; 166 } 167 168 @Override 169 public boolean equals(Object other) { 170 if(this == other) 171 return true; 172 173 if(!hasIdentity()) 174 return false; 175 176 if(other instanceof DateDrivenTermValue) { 177 DateDrivenTermValue that = (DateDrivenTermValue)other; 178 179 if(!that.hasIdentity()) 180 return false; 181 182 Long thisEntityId = getEntityId(); 183 Long thatEntityId = that.getEntityId(); 184 185 boolean objectsEqual = thisEntityId.equals(thatEntityId); 186 if(objectsEqual) 187 objectsEqual = objectsEqual && isIdentical(that); 188 189 return objectsEqual; 190 } else { 191 return false; 192 } 193 } 194 195 public boolean isIdentical(Object other) { 196 if(other instanceof DateDrivenTermValue) { 197 DateDrivenTermValue that = (DateDrivenTermValue)other; 198 boolean objectsEqual = true; 199 200 201 if(objectsEqual) { 202 TermPK thisTermPK = getTermPK(); 203 TermPK thatTermPK = that.getTermPK(); 204 205 if(thisTermPK == null) { 206 objectsEqual = objectsEqual && (thatTermPK == null); 207 } else { 208 objectsEqual = objectsEqual && thisTermPK.equals(thatTermPK); 209 } 210 } 211 212 if(objectsEqual) { 213 Integer thisNetDueDayOfMonth = getNetDueDayOfMonth(); 214 Integer thatNetDueDayOfMonth = that.getNetDueDayOfMonth(); 215 216 if(thisNetDueDayOfMonth == null) { 217 objectsEqual = objectsEqual && (thatNetDueDayOfMonth == null); 218 } else { 219 objectsEqual = objectsEqual && thisNetDueDayOfMonth.equals(thatNetDueDayOfMonth); 220 } 221 } 222 223 if(objectsEqual) { 224 Integer thisDueNextMonthDays = getDueNextMonthDays(); 225 Integer thatDueNextMonthDays = that.getDueNextMonthDays(); 226 227 if(thisDueNextMonthDays == null) { 228 objectsEqual = objectsEqual && (thatDueNextMonthDays == null); 229 } else { 230 objectsEqual = objectsEqual && thisDueNextMonthDays.equals(thatDueNextMonthDays); 231 } 232 } 233 234 if(objectsEqual) { 235 Integer thisDiscountPercentage = getDiscountPercentage(); 236 Integer thatDiscountPercentage = that.getDiscountPercentage(); 237 238 if(thisDiscountPercentage == null) { 239 objectsEqual = objectsEqual && (thatDiscountPercentage == null); 240 } else { 241 objectsEqual = objectsEqual && thisDiscountPercentage.equals(thatDiscountPercentage); 242 } 243 } 244 245 if(objectsEqual) { 246 Integer thisDiscountBeforeDayOfMonth = getDiscountBeforeDayOfMonth(); 247 Integer thatDiscountBeforeDayOfMonth = that.getDiscountBeforeDayOfMonth(); 248 249 if(thisDiscountBeforeDayOfMonth == null) { 250 objectsEqual = objectsEqual && (thatDiscountBeforeDayOfMonth == null); 251 } else { 252 objectsEqual = objectsEqual && thisDiscountBeforeDayOfMonth.equals(thatDiscountBeforeDayOfMonth); 253 } 254 } 255 256 if(objectsEqual) { 257 Long thisFromTime = getFromTime(); 258 Long thatFromTime = that.getFromTime(); 259 260 if(thisFromTime == null) { 261 objectsEqual = objectsEqual && (thatFromTime == null); 262 } else { 263 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 264 } 265 } 266 267 if(objectsEqual) { 268 Long thisThruTime = getThruTime(); 269 Long thatThruTime = that.getThruTime(); 270 271 if(thisThruTime == null) { 272 objectsEqual = objectsEqual && (thatThruTime == null); 273 } else { 274 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 275 } 276 } 277 278 return objectsEqual; 279 } else { 280 return false; 281 } 282 } 283 284 @Override 285 public boolean hasBeenModified() { 286 return termPKHasBeenModified || netDueDayOfMonthHasBeenModified || dueNextMonthDaysHasBeenModified || discountPercentageHasBeenModified || discountBeforeDayOfMonthHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 287 } 288 289 @Override 290 public void clearHasBeenModified() { 291 termPKHasBeenModified = false; 292 netDueDayOfMonthHasBeenModified = false; 293 dueNextMonthDaysHasBeenModified = false; 294 discountPercentageHasBeenModified = false; 295 discountBeforeDayOfMonthHasBeenModified = false; 296 fromTimeHasBeenModified = false; 297 thruTimeHasBeenModified = false; 298 } 299 300 public TermPK getTermPK() { 301 return termPK; 302 } 303 304 public void setTermPK(TermPK termPK) 305 throws PersistenceNotNullException { 306 checkForNull(termPK); 307 308 boolean update = true; 309 310 if(this.termPK != null) { 311 if(this.termPK.equals(termPK)) { 312 update = false; 313 } 314 } else if(termPK == null) { 315 update = false; 316 } 317 318 if(update) { 319 this.termPK = termPK; 320 termPKHasBeenModified = true; 321 clearHashAndString(); 322 } 323 } 324 325 public boolean getTermPKHasBeenModified() { 326 return termPKHasBeenModified; 327 } 328 329 public Integer getNetDueDayOfMonth() { 330 return netDueDayOfMonth; 331 } 332 333 public void setNetDueDayOfMonth(Integer netDueDayOfMonth) 334 throws PersistenceNotNullException { 335 checkForNull(netDueDayOfMonth); 336 337 boolean update = true; 338 339 if(this.netDueDayOfMonth != null) { 340 if(this.netDueDayOfMonth.equals(netDueDayOfMonth)) { 341 update = false; 342 } 343 } else if(netDueDayOfMonth == null) { 344 update = false; 345 } 346 347 if(update) { 348 this.netDueDayOfMonth = netDueDayOfMonth; 349 netDueDayOfMonthHasBeenModified = true; 350 clearHashAndString(); 351 } 352 } 353 354 public boolean getNetDueDayOfMonthHasBeenModified() { 355 return netDueDayOfMonthHasBeenModified; 356 } 357 358 public Integer getDueNextMonthDays() { 359 return dueNextMonthDays; 360 } 361 362 public void setDueNextMonthDays(Integer dueNextMonthDays) 363 throws PersistenceNotNullException { 364 checkForNull(dueNextMonthDays); 365 366 boolean update = true; 367 368 if(this.dueNextMonthDays != null) { 369 if(this.dueNextMonthDays.equals(dueNextMonthDays)) { 370 update = false; 371 } 372 } else if(dueNextMonthDays == null) { 373 update = false; 374 } 375 376 if(update) { 377 this.dueNextMonthDays = dueNextMonthDays; 378 dueNextMonthDaysHasBeenModified = true; 379 clearHashAndString(); 380 } 381 } 382 383 public boolean getDueNextMonthDaysHasBeenModified() { 384 return dueNextMonthDaysHasBeenModified; 385 } 386 387 public Integer getDiscountPercentage() { 388 return discountPercentage; 389 } 390 391 public void setDiscountPercentage(Integer discountPercentage) 392 throws PersistenceNotNullException { 393 checkForNull(discountPercentage); 394 395 boolean update = true; 396 397 if(this.discountPercentage != null) { 398 if(this.discountPercentage.equals(discountPercentage)) { 399 update = false; 400 } 401 } else if(discountPercentage == null) { 402 update = false; 403 } 404 405 if(update) { 406 this.discountPercentage = discountPercentage; 407 discountPercentageHasBeenModified = true; 408 clearHashAndString(); 409 } 410 } 411 412 public boolean getDiscountPercentageHasBeenModified() { 413 return discountPercentageHasBeenModified; 414 } 415 416 public Integer getDiscountBeforeDayOfMonth() { 417 return discountBeforeDayOfMonth; 418 } 419 420 public void setDiscountBeforeDayOfMonth(Integer discountBeforeDayOfMonth) 421 throws PersistenceNotNullException { 422 checkForNull(discountBeforeDayOfMonth); 423 424 boolean update = true; 425 426 if(this.discountBeforeDayOfMonth != null) { 427 if(this.discountBeforeDayOfMonth.equals(discountBeforeDayOfMonth)) { 428 update = false; 429 } 430 } else if(discountBeforeDayOfMonth == null) { 431 update = false; 432 } 433 434 if(update) { 435 this.discountBeforeDayOfMonth = discountBeforeDayOfMonth; 436 discountBeforeDayOfMonthHasBeenModified = true; 437 clearHashAndString(); 438 } 439 } 440 441 public boolean getDiscountBeforeDayOfMonthHasBeenModified() { 442 return discountBeforeDayOfMonthHasBeenModified; 443 } 444 445 public Long getFromTime() { 446 return fromTime; 447 } 448 449 public void setFromTime(Long fromTime) 450 throws PersistenceNotNullException { 451 checkForNull(fromTime); 452 453 boolean update = true; 454 455 if(this.fromTime != null) { 456 if(this.fromTime.equals(fromTime)) { 457 update = false; 458 } 459 } else if(fromTime == null) { 460 update = false; 461 } 462 463 if(update) { 464 this.fromTime = fromTime; 465 fromTimeHasBeenModified = true; 466 clearHashAndString(); 467 } 468 } 469 470 public boolean getFromTimeHasBeenModified() { 471 return fromTimeHasBeenModified; 472 } 473 474 public Long getThruTime() { 475 return thruTime; 476 } 477 478 public void setThruTime(Long thruTime) 479 throws PersistenceNotNullException { 480 checkForNull(thruTime); 481 482 boolean update = true; 483 484 if(this.thruTime != null) { 485 if(this.thruTime.equals(thruTime)) { 486 update = false; 487 } 488 } else if(thruTime == null) { 489 update = false; 490 } 491 492 if(update) { 493 this.thruTime = thruTime; 494 thruTimeHasBeenModified = true; 495 clearHashAndString(); 496 } 497 } 498 499 public boolean getThruTimeHasBeenModified() { 500 return thruTimeHasBeenModified; 501 } 502 503}