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