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 * PaymentCheckValue.java 021 */ 022 023package com.echothree.model.data.payment.server.value; 024 025import com.echothree.model.data.payment.common.pk.PaymentCheckPK; 026 027import com.echothree.model.data.payment.server.factory.PaymentCheckFactory; 028 029import com.echothree.model.data.payment.common.pk.PaymentPK; 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 038import javax.annotation.Nonnull; 039import javax.annotation.Nullable; 040 041public class PaymentCheckValue 042 extends BaseValue<PaymentCheckPK> 043 implements Cloneable, Serializable { 044 045 private PaymentPK paymentPK; 046 private boolean paymentPKHasBeenModified = false; 047 private String reference; 048 private boolean referenceHasBeenModified = false; 049 private Long fromTime; 050 private boolean fromTimeHasBeenModified = false; 051 private Long thruTime; 052 private boolean thruTimeHasBeenModified = false; 053 054 private transient Integer _hashCode = null; 055 private transient String _stringValue = null; 056 057 private void constructFields(PaymentPK paymentPK, String reference, Long fromTime, Long thruTime) 058 throws PersistenceNotNullException { 059 this.paymentPK = paymentPK; 060 checkForNull(reference); 061 this.reference = reference; 062 checkForNull(fromTime); 063 this.fromTime = fromTime; 064 checkForNull(thruTime); 065 this.thruTime = thruTime; 066 } 067 068 /** Creates a new instance of PaymentCheckValue */ 069 public PaymentCheckValue(PaymentCheckPK paymentCheckPK, PaymentPK paymentPK, String reference, Long fromTime, Long thruTime) 070 throws PersistenceNotNullException { 071 super(paymentCheckPK); 072 constructFields(paymentPK, reference, fromTime, thruTime); 073 } 074 075 /** Creates a new instance of PaymentCheckValue */ 076 public PaymentCheckValue(PaymentPK paymentPK, String reference, Long fromTime, Long thruTime) 077 throws PersistenceNotNullException { 078 super(); 079 constructFields(paymentPK, reference, fromTime, thruTime); 080 } 081 082 @Override 083 @Nonnull 084 public PaymentCheckFactory getBaseFactoryInstance() { 085 return PaymentCheckFactory.getInstance(); 086 } 087 088 @Override 089 @Nonnull 090 public PaymentCheckValue clone() { 091 Object result; 092 093 try { 094 result = super.clone(); 095 } catch (CloneNotSupportedException cnse) { 096 // This shouldn't happen, fail when it does. 097 throw new PersistenceCloneException(cnse); 098 } 099 100 return (PaymentCheckValue)result; 101 } 102 103 @Override 104 @Nonnull 105 public PaymentCheckPK getPrimaryKey() { 106 if(_primaryKey == null) { 107 _primaryKey = new PaymentCheckPK(entityId); 108 } 109 110 return _primaryKey; 111 } 112 113 private void clearHashAndString() { 114 _hashCode = null; 115 _stringValue = null; 116 } 117 118 @Override 119 public int hashCode() { 120 if(_hashCode == null) { 121 int hashCode = 17; 122 123 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 124 125 hashCode = 37 * hashCode + ((paymentPK != null) ? paymentPK.hashCode() : 0); 126 hashCode = 37 * hashCode + ((reference != null) ? reference.hashCode() : 0); 127 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 128 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 129 130 _hashCode = hashCode; 131 } 132 133 return _hashCode; 134 } 135 136 @Override 137 @Nonnull 138 public String toString() { 139 if(_stringValue == null) { 140 _stringValue = "{" + 141 "entityId=" + getEntityId() + 142 ", paymentPK=" + getPaymentPK() + 143 ", reference=" + getReference() + 144 ", fromTime=" + getFromTime() + 145 ", thruTime=" + getThruTime() + 146 "}"; 147 } 148 return _stringValue; 149 } 150 151 @Override 152 public boolean equals(Object other) { 153 if(this == other) 154 return true; 155 156 if(!hasIdentity()) 157 return false; 158 159 if(other instanceof PaymentCheckValue that) { 160 if(!that.hasIdentity()) 161 return false; 162 163 Long thisEntityId = getEntityId(); 164 Long thatEntityId = that.getEntityId(); 165 166 boolean objectsEqual = thisEntityId.equals(thatEntityId); 167 if(objectsEqual) 168 objectsEqual = isIdentical(that); 169 170 return objectsEqual; 171 } else { 172 return false; 173 } 174 } 175 176 public boolean isIdentical(Object other) { 177 if(other instanceof PaymentCheckValue that) { 178 boolean objectsEqual = true; 179 180 181 if(objectsEqual) { 182 PaymentPK thisPaymentPK = getPaymentPK(); 183 PaymentPK thatPaymentPK = that.getPaymentPK(); 184 185 if(thisPaymentPK == null) { 186 objectsEqual = objectsEqual && (thatPaymentPK == null); 187 } else { 188 objectsEqual = objectsEqual && thisPaymentPK.equals(thatPaymentPK); 189 } 190 } 191 192 if(objectsEqual) { 193 String thisReference = getReference(); 194 String thatReference = that.getReference(); 195 196 if(thisReference == null) { 197 objectsEqual = objectsEqual && (thatReference == null); 198 } else { 199 objectsEqual = objectsEqual && thisReference.equals(thatReference); 200 } 201 } 202 203 if(objectsEqual) { 204 Long thisFromTime = getFromTime(); 205 Long thatFromTime = that.getFromTime(); 206 207 if(thisFromTime == null) { 208 objectsEqual = objectsEqual && (thatFromTime == null); 209 } else { 210 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 211 } 212 } 213 214 if(objectsEqual) { 215 Long thisThruTime = getThruTime(); 216 Long thatThruTime = that.getThruTime(); 217 218 if(thisThruTime == null) { 219 objectsEqual = objectsEqual && (thatThruTime == null); 220 } else { 221 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 222 } 223 } 224 225 return objectsEqual; 226 } else { 227 return false; 228 } 229 } 230 231 @Override 232 public boolean hasBeenModified() { 233 return paymentPKHasBeenModified || referenceHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 234 } 235 236 @Override 237 public void clearHasBeenModified() { 238 paymentPKHasBeenModified = false; 239 referenceHasBeenModified = false; 240 fromTimeHasBeenModified = false; 241 thruTimeHasBeenModified = false; 242 } 243 244 @Nullable 245 public PaymentPK getPaymentPK() { 246 return paymentPK; 247 } 248 249 public void setPaymentPK(@Nullable PaymentPK paymentPK) { 250 boolean update = true; 251 252 if(this.paymentPK != null) { 253 if(this.paymentPK.equals(paymentPK)) { 254 update = false; 255 } 256 } else if(paymentPK == null) { 257 update = false; 258 } 259 260 if(update) { 261 this.paymentPK = paymentPK; 262 paymentPKHasBeenModified = true; 263 clearHashAndString(); 264 } 265 } 266 267 public boolean getPaymentPKHasBeenModified() { 268 return paymentPKHasBeenModified; 269 } 270 271 @Nonnull 272 public String getReference() { 273 return reference; 274 } 275 276 public void setReference(@Nonnull String reference) 277 throws PersistenceNotNullException { 278 checkForNull(reference); 279 280 boolean update = true; 281 282 if(this.reference != null) { 283 if(this.reference.equals(reference)) { 284 update = false; 285 } 286 } else if(reference == null) { 287 update = false; 288 } 289 290 if(update) { 291 this.reference = reference; 292 referenceHasBeenModified = true; 293 clearHashAndString(); 294 } 295 } 296 297 public boolean getReferenceHasBeenModified() { 298 return referenceHasBeenModified; 299 } 300 301 @Nonnull 302 public Long getFromTime() { 303 return fromTime; 304 } 305 306 public void setFromTime(@Nonnull Long fromTime) 307 throws PersistenceNotNullException { 308 checkForNull(fromTime); 309 310 boolean update = true; 311 312 if(this.fromTime != null) { 313 if(this.fromTime.equals(fromTime)) { 314 update = false; 315 } 316 } else if(fromTime == null) { 317 update = false; 318 } 319 320 if(update) { 321 this.fromTime = fromTime; 322 fromTimeHasBeenModified = true; 323 clearHashAndString(); 324 } 325 } 326 327 public boolean getFromTimeHasBeenModified() { 328 return fromTimeHasBeenModified; 329 } 330 331 @Nonnull 332 public Long getThruTime() { 333 return thruTime; 334 } 335 336 public void setThruTime(@Nonnull Long thruTime) 337 throws PersistenceNotNullException { 338 checkForNull(thruTime); 339 340 boolean update = true; 341 342 if(this.thruTime != null) { 343 if(this.thruTime.equals(thruTime)) { 344 update = false; 345 } 346 } else if(thruTime == null) { 347 update = false; 348 } 349 350 if(update) { 351 this.thruTime = thruTime; 352 thruTimeHasBeenModified = true; 353 clearHashAndString(); 354 } 355 } 356 357 public boolean getThruTimeHasBeenModified() { 358 return thruTimeHasBeenModified; 359 } 360 361}