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