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