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 * InvoiceRoleValue.java 021 */ 022 023package com.echothree.model.data.invoice.server.value; 024 025import com.echothree.model.data.invoice.common.pk.InvoiceRolePK; 026 027import com.echothree.model.data.invoice.server.factory.InvoiceRoleFactory; 028 029import com.echothree.model.data.invoice.common.pk.InvoicePK; 030import com.echothree.model.data.party.common.pk.PartyPK; 031import com.echothree.model.data.contact.common.pk.PartyContactMechanismPK; 032import com.echothree.model.data.invoice.common.pk.InvoiceRoleTypePK; 033 034import com.echothree.util.common.exception.PersistenceCloneException; 035import com.echothree.util.common.exception.PersistenceNotNullException; 036 037import com.echothree.util.server.persistence.BaseValue; 038 039import java.io.Serializable; 040 041public class InvoiceRoleValue 042 extends BaseValue<InvoiceRolePK> 043 implements Cloneable, Serializable { 044 045 private InvoicePK invoicePK; 046 private boolean invoicePKHasBeenModified = false; 047 private PartyPK partyPK; 048 private boolean partyPKHasBeenModified = false; 049 private PartyContactMechanismPK partyContactMechanismPK; 050 private boolean partyContactMechanismPKHasBeenModified = false; 051 private InvoiceRoleTypePK invoiceRoleTypePK; 052 private boolean invoiceRoleTypePKHasBeenModified = false; 053 private Long fromTime; 054 private boolean fromTimeHasBeenModified = false; 055 private Long thruTime; 056 private boolean thruTimeHasBeenModified = false; 057 058 private transient Integer _hashCode = null; 059 private transient String _stringValue = null; 060 061 private void constructFields(InvoicePK invoicePK, PartyPK partyPK, PartyContactMechanismPK partyContactMechanismPK, InvoiceRoleTypePK invoiceRoleTypePK, Long fromTime, Long thruTime) 062 throws PersistenceNotNullException { 063 checkForNull(invoicePK); 064 this.invoicePK = invoicePK; 065 checkForNull(partyPK); 066 this.partyPK = partyPK; 067 checkForNull(partyContactMechanismPK); 068 this.partyContactMechanismPK = partyContactMechanismPK; 069 checkForNull(invoiceRoleTypePK); 070 this.invoiceRoleTypePK = invoiceRoleTypePK; 071 checkForNull(fromTime); 072 this.fromTime = fromTime; 073 checkForNull(thruTime); 074 this.thruTime = thruTime; 075 } 076 077 /** Creates a new instance of InvoiceRoleValue */ 078 public InvoiceRoleValue(InvoiceRolePK invoiceRolePK, InvoicePK invoicePK, PartyPK partyPK, PartyContactMechanismPK partyContactMechanismPK, InvoiceRoleTypePK invoiceRoleTypePK, Long fromTime, Long thruTime) 079 throws PersistenceNotNullException { 080 super(invoiceRolePK); 081 constructFields(invoicePK, partyPK, partyContactMechanismPK, invoiceRoleTypePK, fromTime, thruTime); 082 } 083 084 /** Creates a new instance of InvoiceRoleValue */ 085 public InvoiceRoleValue(InvoicePK invoicePK, PartyPK partyPK, PartyContactMechanismPK partyContactMechanismPK, InvoiceRoleTypePK invoiceRoleTypePK, Long fromTime, Long thruTime) 086 throws PersistenceNotNullException { 087 super(); 088 constructFields(invoicePK, partyPK, partyContactMechanismPK, invoiceRoleTypePK, fromTime, thruTime); 089 } 090 091 @Override 092 public InvoiceRoleFactory getBaseFactoryInstance() { 093 return InvoiceRoleFactory.getInstance(); 094 } 095 096 @Override 097 public InvoiceRoleValue clone() { 098 Object result; 099 100 try { 101 result = super.clone(); 102 } catch (CloneNotSupportedException cnse) { 103 // This shouldn't happen, fail when it does. 104 throw new PersistenceCloneException(cnse); 105 } 106 107 return (InvoiceRoleValue)result; 108 } 109 110 @Override 111 public InvoiceRolePK getPrimaryKey() { 112 if(_primaryKey == null) { 113 _primaryKey = new InvoiceRolePK(entityId); 114 } 115 116 return _primaryKey; 117 } 118 119 private void clearHashAndString() { 120 _hashCode = null; 121 _stringValue = null; 122 } 123 124 @Override 125 public int hashCode() { 126 if(_hashCode == null) { 127 int hashCode = 17; 128 129 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 130 131 hashCode = 37 * hashCode + ((invoicePK != null) ? invoicePK.hashCode() : 0); 132 hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0); 133 hashCode = 37 * hashCode + ((partyContactMechanismPK != null) ? partyContactMechanismPK.hashCode() : 0); 134 hashCode = 37 * hashCode + ((invoiceRoleTypePK != null) ? invoiceRoleTypePK.hashCode() : 0); 135 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 136 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 137 138 _hashCode = hashCode; 139 } 140 141 return _hashCode; 142 } 143 144 @Override 145 public String toString() { 146 if(_stringValue == null) { 147 StringBuilder stringValue = new StringBuilder("{"); 148 149 stringValue.append("entityId=").append(getEntityId()); 150 151 stringValue.append(", invoicePK=").append(getInvoicePK()); 152 stringValue.append(", partyPK=").append(getPartyPK()); 153 stringValue.append(", partyContactMechanismPK=").append(getPartyContactMechanismPK()); 154 stringValue.append(", invoiceRoleTypePK=").append(getInvoiceRoleTypePK()); 155 stringValue.append(", fromTime=").append(getFromTime()); 156 stringValue.append(", thruTime=").append(getThruTime()); 157 158 stringValue.append('}'); 159 160 _stringValue = stringValue.toString(); 161 } 162 return _stringValue; 163 } 164 165 @Override 166 public boolean equals(Object other) { 167 if(this == other) 168 return true; 169 170 if(!hasIdentity()) 171 return false; 172 173 if(other instanceof InvoiceRoleValue) { 174 InvoiceRoleValue that = (InvoiceRoleValue)other; 175 176 if(!that.hasIdentity()) 177 return false; 178 179 Long thisEntityId = getEntityId(); 180 Long thatEntityId = that.getEntityId(); 181 182 boolean objectsEqual = thisEntityId.equals(thatEntityId); 183 if(objectsEqual) 184 objectsEqual = objectsEqual && isIdentical(that); 185 186 return objectsEqual; 187 } else { 188 return false; 189 } 190 } 191 192 public boolean isIdentical(Object other) { 193 if(other instanceof InvoiceRoleValue) { 194 InvoiceRoleValue that = (InvoiceRoleValue)other; 195 boolean objectsEqual = true; 196 197 198 if(objectsEqual) { 199 InvoicePK thisInvoicePK = getInvoicePK(); 200 InvoicePK thatInvoicePK = that.getInvoicePK(); 201 202 if(thisInvoicePK == null) { 203 objectsEqual = objectsEqual && (thatInvoicePK == null); 204 } else { 205 objectsEqual = objectsEqual && thisInvoicePK.equals(thatInvoicePK); 206 } 207 } 208 209 if(objectsEqual) { 210 PartyPK thisPartyPK = getPartyPK(); 211 PartyPK thatPartyPK = that.getPartyPK(); 212 213 if(thisPartyPK == null) { 214 objectsEqual = objectsEqual && (thatPartyPK == null); 215 } else { 216 objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK); 217 } 218 } 219 220 if(objectsEqual) { 221 PartyContactMechanismPK thisPartyContactMechanismPK = getPartyContactMechanismPK(); 222 PartyContactMechanismPK thatPartyContactMechanismPK = that.getPartyContactMechanismPK(); 223 224 if(thisPartyContactMechanismPK == null) { 225 objectsEqual = objectsEqual && (thatPartyContactMechanismPK == null); 226 } else { 227 objectsEqual = objectsEqual && thisPartyContactMechanismPK.equals(thatPartyContactMechanismPK); 228 } 229 } 230 231 if(objectsEqual) { 232 InvoiceRoleTypePK thisInvoiceRoleTypePK = getInvoiceRoleTypePK(); 233 InvoiceRoleTypePK thatInvoiceRoleTypePK = that.getInvoiceRoleTypePK(); 234 235 if(thisInvoiceRoleTypePK == null) { 236 objectsEqual = objectsEqual && (thatInvoiceRoleTypePK == null); 237 } else { 238 objectsEqual = objectsEqual && thisInvoiceRoleTypePK.equals(thatInvoiceRoleTypePK); 239 } 240 } 241 242 if(objectsEqual) { 243 Long thisFromTime = getFromTime(); 244 Long thatFromTime = that.getFromTime(); 245 246 if(thisFromTime == null) { 247 objectsEqual = objectsEqual && (thatFromTime == null); 248 } else { 249 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 250 } 251 } 252 253 if(objectsEqual) { 254 Long thisThruTime = getThruTime(); 255 Long thatThruTime = that.getThruTime(); 256 257 if(thisThruTime == null) { 258 objectsEqual = objectsEqual && (thatThruTime == null); 259 } else { 260 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 261 } 262 } 263 264 return objectsEqual; 265 } else { 266 return false; 267 } 268 } 269 270 @Override 271 public boolean hasBeenModified() { 272 return invoicePKHasBeenModified || partyPKHasBeenModified || partyContactMechanismPKHasBeenModified || invoiceRoleTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 273 } 274 275 @Override 276 public void clearHasBeenModified() { 277 invoicePKHasBeenModified = false; 278 partyPKHasBeenModified = false; 279 partyContactMechanismPKHasBeenModified = false; 280 invoiceRoleTypePKHasBeenModified = false; 281 fromTimeHasBeenModified = false; 282 thruTimeHasBeenModified = false; 283 } 284 285 public InvoicePK getInvoicePK() { 286 return invoicePK; 287 } 288 289 public void setInvoicePK(InvoicePK invoicePK) 290 throws PersistenceNotNullException { 291 checkForNull(invoicePK); 292 293 boolean update = true; 294 295 if(this.invoicePK != null) { 296 if(this.invoicePK.equals(invoicePK)) { 297 update = false; 298 } 299 } else if(invoicePK == null) { 300 update = false; 301 } 302 303 if(update) { 304 this.invoicePK = invoicePK; 305 invoicePKHasBeenModified = true; 306 clearHashAndString(); 307 } 308 } 309 310 public boolean getInvoicePKHasBeenModified() { 311 return invoicePKHasBeenModified; 312 } 313 314 public PartyPK getPartyPK() { 315 return partyPK; 316 } 317 318 public void setPartyPK(PartyPK partyPK) 319 throws PersistenceNotNullException { 320 checkForNull(partyPK); 321 322 boolean update = true; 323 324 if(this.partyPK != null) { 325 if(this.partyPK.equals(partyPK)) { 326 update = false; 327 } 328 } else if(partyPK == null) { 329 update = false; 330 } 331 332 if(update) { 333 this.partyPK = partyPK; 334 partyPKHasBeenModified = true; 335 clearHashAndString(); 336 } 337 } 338 339 public boolean getPartyPKHasBeenModified() { 340 return partyPKHasBeenModified; 341 } 342 343 public PartyContactMechanismPK getPartyContactMechanismPK() { 344 return partyContactMechanismPK; 345 } 346 347 public void setPartyContactMechanismPK(PartyContactMechanismPK partyContactMechanismPK) 348 throws PersistenceNotNullException { 349 checkForNull(partyContactMechanismPK); 350 351 boolean update = true; 352 353 if(this.partyContactMechanismPK != null) { 354 if(this.partyContactMechanismPK.equals(partyContactMechanismPK)) { 355 update = false; 356 } 357 } else if(partyContactMechanismPK == null) { 358 update = false; 359 } 360 361 if(update) { 362 this.partyContactMechanismPK = partyContactMechanismPK; 363 partyContactMechanismPKHasBeenModified = true; 364 clearHashAndString(); 365 } 366 } 367 368 public boolean getPartyContactMechanismPKHasBeenModified() { 369 return partyContactMechanismPKHasBeenModified; 370 } 371 372 public InvoiceRoleTypePK getInvoiceRoleTypePK() { 373 return invoiceRoleTypePK; 374 } 375 376 public void setInvoiceRoleTypePK(InvoiceRoleTypePK invoiceRoleTypePK) 377 throws PersistenceNotNullException { 378 checkForNull(invoiceRoleTypePK); 379 380 boolean update = true; 381 382 if(this.invoiceRoleTypePK != null) { 383 if(this.invoiceRoleTypePK.equals(invoiceRoleTypePK)) { 384 update = false; 385 } 386 } else if(invoiceRoleTypePK == null) { 387 update = false; 388 } 389 390 if(update) { 391 this.invoiceRoleTypePK = invoiceRoleTypePK; 392 invoiceRoleTypePKHasBeenModified = true; 393 clearHashAndString(); 394 } 395 } 396 397 public boolean getInvoiceRoleTypePKHasBeenModified() { 398 return invoiceRoleTypePKHasBeenModified; 399 } 400 401 public Long getFromTime() { 402 return fromTime; 403 } 404 405 public void setFromTime(Long fromTime) 406 throws PersistenceNotNullException { 407 checkForNull(fromTime); 408 409 boolean update = true; 410 411 if(this.fromTime != null) { 412 if(this.fromTime.equals(fromTime)) { 413 update = false; 414 } 415 } else if(fromTime == null) { 416 update = false; 417 } 418 419 if(update) { 420 this.fromTime = fromTime; 421 fromTimeHasBeenModified = true; 422 clearHashAndString(); 423 } 424 } 425 426 public boolean getFromTimeHasBeenModified() { 427 return fromTimeHasBeenModified; 428 } 429 430 public Long getThruTime() { 431 return thruTime; 432 } 433 434 public void setThruTime(Long thruTime) 435 throws PersistenceNotNullException { 436 checkForNull(thruTime); 437 438 boolean update = true; 439 440 if(this.thruTime != null) { 441 if(this.thruTime.equals(thruTime)) { 442 update = false; 443 } 444 } else if(thruTime == null) { 445 update = false; 446 } 447 448 if(update) { 449 this.thruTime = thruTime; 450 thruTimeHasBeenModified = true; 451 clearHashAndString(); 452 } 453 } 454 455 public boolean getThruTimeHasBeenModified() { 456 return thruTimeHasBeenModified; 457 } 458 459}