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