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