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 * ContactInet4AddressValue.java 021 */ 022 023package com.echothree.model.data.contact.server.value; 024 025import com.echothree.model.data.contact.common.pk.ContactInet4AddressPK; 026 027import com.echothree.model.data.contact.server.factory.ContactInet4AddressFactory; 028 029import com.echothree.model.data.contact.common.pk.ContactMechanismPK; 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 ContactInet4AddressValue 039 extends BaseValue<ContactInet4AddressPK> 040 implements Cloneable, Serializable { 041 042 private ContactMechanismPK contactMechanismPK; 043 private boolean contactMechanismPKHasBeenModified = false; 044 private Integer inet4Address; 045 private boolean inet4AddressHasBeenModified = false; 046 private Long fromTime; 047 private boolean fromTimeHasBeenModified = false; 048 private Long thruTime; 049 private boolean thruTimeHasBeenModified = false; 050 051 private transient Integer _hashCode = null; 052 private transient String _stringValue = null; 053 054 private void constructFields(ContactMechanismPK contactMechanismPK, Integer inet4Address, Long fromTime, Long thruTime) 055 throws PersistenceNotNullException { 056 checkForNull(contactMechanismPK); 057 this.contactMechanismPK = contactMechanismPK; 058 checkForNull(inet4Address); 059 this.inet4Address = inet4Address; 060 checkForNull(fromTime); 061 this.fromTime = fromTime; 062 checkForNull(thruTime); 063 this.thruTime = thruTime; 064 } 065 066 /** Creates a new instance of ContactInet4AddressValue */ 067 public ContactInet4AddressValue(ContactInet4AddressPK contactInet4AddressPK, ContactMechanismPK contactMechanismPK, Integer inet4Address, Long fromTime, Long thruTime) 068 throws PersistenceNotNullException { 069 super(contactInet4AddressPK); 070 constructFields(contactMechanismPK, inet4Address, fromTime, thruTime); 071 } 072 073 /** Creates a new instance of ContactInet4AddressValue */ 074 public ContactInet4AddressValue(ContactMechanismPK contactMechanismPK, Integer inet4Address, Long fromTime, Long thruTime) 075 throws PersistenceNotNullException { 076 super(); 077 constructFields(contactMechanismPK, inet4Address, fromTime, thruTime); 078 } 079 080 @Override 081 public ContactInet4AddressFactory getBaseFactoryInstance() { 082 return ContactInet4AddressFactory.getInstance(); 083 } 084 085 @Override 086 public ContactInet4AddressValue clone() { 087 Object result; 088 089 try { 090 result = super.clone(); 091 } catch (CloneNotSupportedException cnse) { 092 // This shouldn't happen, fail when it does. 093 throw new PersistenceCloneException(cnse); 094 } 095 096 return (ContactInet4AddressValue)result; 097 } 098 099 @Override 100 public ContactInet4AddressPK getPrimaryKey() { 101 if(_primaryKey == null) { 102 _primaryKey = new ContactInet4AddressPK(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 + ((contactMechanismPK != null) ? contactMechanismPK.hashCode() : 0); 121 hashCode = 37 * hashCode + ((inet4Address != null) ? inet4Address.hashCode() : 0); 122 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 123 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 124 125 _hashCode = hashCode; 126 } 127 128 return _hashCode; 129 } 130 131 @Override 132 public String toString() { 133 if(_stringValue == null) { 134 StringBuilder stringValue = new StringBuilder("{"); 135 136 stringValue.append("entityId=").append(getEntityId()); 137 138 stringValue.append(", contactMechanismPK=").append(getContactMechanismPK()); 139 stringValue.append(", inet4Address=").append(getInet4Address()); 140 stringValue.append(", fromTime=").append(getFromTime()); 141 stringValue.append(", thruTime=").append(getThruTime()); 142 143 stringValue.append('}'); 144 145 _stringValue = stringValue.toString(); 146 } 147 return _stringValue; 148 } 149 150 @Override 151 public boolean equals(Object other) { 152 if(this == other) 153 return true; 154 155 if(!hasIdentity()) 156 return false; 157 158 if(other instanceof ContactInet4AddressValue) { 159 ContactInet4AddressValue that = (ContactInet4AddressValue)other; 160 161 if(!that.hasIdentity()) 162 return false; 163 164 Long thisEntityId = getEntityId(); 165 Long thatEntityId = that.getEntityId(); 166 167 boolean objectsEqual = thisEntityId.equals(thatEntityId); 168 if(objectsEqual) 169 objectsEqual = objectsEqual && isIdentical(that); 170 171 return objectsEqual; 172 } else { 173 return false; 174 } 175 } 176 177 public boolean isIdentical(Object other) { 178 if(other instanceof ContactInet4AddressValue) { 179 ContactInet4AddressValue that = (ContactInet4AddressValue)other; 180 boolean objectsEqual = true; 181 182 183 if(objectsEqual) { 184 ContactMechanismPK thisContactMechanismPK = getContactMechanismPK(); 185 ContactMechanismPK thatContactMechanismPK = that.getContactMechanismPK(); 186 187 if(thisContactMechanismPK == null) { 188 objectsEqual = objectsEqual && (thatContactMechanismPK == null); 189 } else { 190 objectsEqual = objectsEqual && thisContactMechanismPK.equals(thatContactMechanismPK); 191 } 192 } 193 194 if(objectsEqual) { 195 Integer thisInet4Address = getInet4Address(); 196 Integer thatInet4Address = that.getInet4Address(); 197 198 if(thisInet4Address == null) { 199 objectsEqual = objectsEqual && (thatInet4Address == null); 200 } else { 201 objectsEqual = objectsEqual && thisInet4Address.equals(thatInet4Address); 202 } 203 } 204 205 if(objectsEqual) { 206 Long thisFromTime = getFromTime(); 207 Long thatFromTime = that.getFromTime(); 208 209 if(thisFromTime == null) { 210 objectsEqual = objectsEqual && (thatFromTime == null); 211 } else { 212 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 213 } 214 } 215 216 if(objectsEqual) { 217 Long thisThruTime = getThruTime(); 218 Long thatThruTime = that.getThruTime(); 219 220 if(thisThruTime == null) { 221 objectsEqual = objectsEqual && (thatThruTime == null); 222 } else { 223 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 224 } 225 } 226 227 return objectsEqual; 228 } else { 229 return false; 230 } 231 } 232 233 @Override 234 public boolean hasBeenModified() { 235 return contactMechanismPKHasBeenModified || inet4AddressHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 236 } 237 238 @Override 239 public void clearHasBeenModified() { 240 contactMechanismPKHasBeenModified = false; 241 inet4AddressHasBeenModified = false; 242 fromTimeHasBeenModified = false; 243 thruTimeHasBeenModified = false; 244 } 245 246 public ContactMechanismPK getContactMechanismPK() { 247 return contactMechanismPK; 248 } 249 250 public void setContactMechanismPK(ContactMechanismPK contactMechanismPK) 251 throws PersistenceNotNullException { 252 checkForNull(contactMechanismPK); 253 254 boolean update = true; 255 256 if(this.contactMechanismPK != null) { 257 if(this.contactMechanismPK.equals(contactMechanismPK)) { 258 update = false; 259 } 260 } else if(contactMechanismPK == null) { 261 update = false; 262 } 263 264 if(update) { 265 this.contactMechanismPK = contactMechanismPK; 266 contactMechanismPKHasBeenModified = true; 267 clearHashAndString(); 268 } 269 } 270 271 public boolean getContactMechanismPKHasBeenModified() { 272 return contactMechanismPKHasBeenModified; 273 } 274 275 public Integer getInet4Address() { 276 return inet4Address; 277 } 278 279 public void setInet4Address(Integer inet4Address) 280 throws PersistenceNotNullException { 281 checkForNull(inet4Address); 282 283 boolean update = true; 284 285 if(this.inet4Address != null) { 286 if(this.inet4Address.equals(inet4Address)) { 287 update = false; 288 } 289 } else if(inet4Address == null) { 290 update = false; 291 } 292 293 if(update) { 294 this.inet4Address = inet4Address; 295 inet4AddressHasBeenModified = true; 296 clearHashAndString(); 297 } 298 } 299 300 public boolean getInet4AddressHasBeenModified() { 301 return inet4AddressHasBeenModified; 302 } 303 304 public Long getFromTime() { 305 return fromTime; 306 } 307 308 public void setFromTime(Long fromTime) 309 throws PersistenceNotNullException { 310 checkForNull(fromTime); 311 312 boolean update = true; 313 314 if(this.fromTime != null) { 315 if(this.fromTime.equals(fromTime)) { 316 update = false; 317 } 318 } else if(fromTime == null) { 319 update = false; 320 } 321 322 if(update) { 323 this.fromTime = fromTime; 324 fromTimeHasBeenModified = true; 325 clearHashAndString(); 326 } 327 } 328 329 public boolean getFromTimeHasBeenModified() { 330 return fromTimeHasBeenModified; 331 } 332 333 public Long getThruTime() { 334 return thruTime; 335 } 336 337 public void setThruTime(Long thruTime) 338 throws PersistenceNotNullException { 339 checkForNull(thruTime); 340 341 boolean update = true; 342 343 if(this.thruTime != null) { 344 if(this.thruTime.equals(thruTime)) { 345 update = false; 346 } 347 } else if(thruTime == null) { 348 update = false; 349 } 350 351 if(update) { 352 this.thruTime = thruTime; 353 thruTimeHasBeenModified = true; 354 clearHashAndString(); 355 } 356 } 357 358 public boolean getThruTimeHasBeenModified() { 359 return thruTimeHasBeenModified; 360 } 361 362}