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 * 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 StringBuilder stringValue = new StringBuilder("{"); 129 130 stringValue.append("entityId=").append(getEntityId()); 131 132 stringValue.append(", paymentPK=").append(getPaymentPK()); 133 stringValue.append(", fromTime=").append(getFromTime()); 134 stringValue.append(", thruTime=").append(getThruTime()); 135 136 stringValue.append('}'); 137 138 _stringValue = stringValue.toString(); 139 } 140 return _stringValue; 141 } 142 143 @Override 144 public boolean equals(Object other) { 145 if(this == other) 146 return true; 147 148 if(!hasIdentity()) 149 return false; 150 151 if(other instanceof PaymentCreditCardValue) { 152 PaymentCreditCardValue that = (PaymentCreditCardValue)other; 153 154 if(!that.hasIdentity()) 155 return false; 156 157 Long thisEntityId = getEntityId(); 158 Long thatEntityId = that.getEntityId(); 159 160 boolean objectsEqual = thisEntityId.equals(thatEntityId); 161 if(objectsEqual) 162 objectsEqual = objectsEqual && isIdentical(that); 163 164 return objectsEqual; 165 } else { 166 return false; 167 } 168 } 169 170 public boolean isIdentical(Object other) { 171 if(other instanceof PaymentCreditCardValue) { 172 PaymentCreditCardValue that = (PaymentCreditCardValue)other; 173 boolean objectsEqual = true; 174 175 176 if(objectsEqual) { 177 PaymentPK thisPaymentPK = getPaymentPK(); 178 PaymentPK thatPaymentPK = that.getPaymentPK(); 179 180 if(thisPaymentPK == null) { 181 objectsEqual = objectsEqual && (thatPaymentPK == null); 182 } else { 183 objectsEqual = objectsEqual && thisPaymentPK.equals(thatPaymentPK); 184 } 185 } 186 187 if(objectsEqual) { 188 Long thisFromTime = getFromTime(); 189 Long thatFromTime = that.getFromTime(); 190 191 if(thisFromTime == null) { 192 objectsEqual = objectsEqual && (thatFromTime == null); 193 } else { 194 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 195 } 196 } 197 198 if(objectsEqual) { 199 Long thisThruTime = getThruTime(); 200 Long thatThruTime = that.getThruTime(); 201 202 if(thisThruTime == null) { 203 objectsEqual = objectsEqual && (thatThruTime == null); 204 } else { 205 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 206 } 207 } 208 209 return objectsEqual; 210 } else { 211 return false; 212 } 213 } 214 215 @Override 216 public boolean hasBeenModified() { 217 return paymentPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 218 } 219 220 @Override 221 public void clearHasBeenModified() { 222 paymentPKHasBeenModified = false; 223 fromTimeHasBeenModified = false; 224 thruTimeHasBeenModified = false; 225 } 226 227 public PaymentPK getPaymentPK() { 228 return paymentPK; 229 } 230 231 public void setPaymentPK(PaymentPK paymentPK) { 232 boolean update = true; 233 234 if(this.paymentPK != null) { 235 if(this.paymentPK.equals(paymentPK)) { 236 update = false; 237 } 238 } else if(paymentPK == null) { 239 update = false; 240 } 241 242 if(update) { 243 this.paymentPK = paymentPK; 244 paymentPKHasBeenModified = true; 245 clearHashAndString(); 246 } 247 } 248 249 public boolean getPaymentPKHasBeenModified() { 250 return paymentPKHasBeenModified; 251 } 252 253 public Long getFromTime() { 254 return fromTime; 255 } 256 257 public void setFromTime(Long fromTime) 258 throws PersistenceNotNullException { 259 checkForNull(fromTime); 260 261 boolean update = true; 262 263 if(this.fromTime != null) { 264 if(this.fromTime.equals(fromTime)) { 265 update = false; 266 } 267 } else if(fromTime == null) { 268 update = false; 269 } 270 271 if(update) { 272 this.fromTime = fromTime; 273 fromTimeHasBeenModified = true; 274 clearHashAndString(); 275 } 276 } 277 278 public boolean getFromTimeHasBeenModified() { 279 return fromTimeHasBeenModified; 280 } 281 282 public Long getThruTime() { 283 return thruTime; 284 } 285 286 public void setThruTime(Long thruTime) 287 throws PersistenceNotNullException { 288 checkForNull(thruTime); 289 290 boolean update = true; 291 292 if(this.thruTime != null) { 293 if(this.thruTime.equals(thruTime)) { 294 update = false; 295 } 296 } else if(thruTime == null) { 297 update = false; 298 } 299 300 if(update) { 301 this.thruTime = thruTime; 302 thruTimeHasBeenModified = true; 303 clearHashAndString(); 304 } 305 } 306 307 public boolean getThruTimeHasBeenModified() { 308 return thruTimeHasBeenModified; 309 } 310 311}