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 * EntityAttributeNumericValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.EntityAttributeNumericPK; 026 027import com.echothree.model.data.core.server.factory.EntityAttributeNumericFactory; 028 029import com.echothree.model.data.core.common.pk.EntityAttributePK; 030import com.echothree.model.data.uom.common.pk.UnitOfMeasureTypePK; 031 032import com.echothree.util.common.exception.PersistenceCloneException; 033import com.echothree.util.common.exception.PersistenceNotNullException; 034 035import com.echothree.util.server.persistence.BaseValue; 036 037import java.io.Serializable; 038 039public class EntityAttributeNumericValue 040 extends BaseValue<EntityAttributeNumericPK> 041 implements Cloneable, Serializable { 042 043 private EntityAttributePK entityAttributePK; 044 private boolean entityAttributePKHasBeenModified = false; 045 private UnitOfMeasureTypePK unitOfMeasureTypePK; 046 private boolean unitOfMeasureTypePKHasBeenModified = false; 047 private Long fromTime; 048 private boolean fromTimeHasBeenModified = false; 049 private Long thruTime; 050 private boolean thruTimeHasBeenModified = false; 051 052 private transient Integer _hashCode = null; 053 private transient String _stringValue = null; 054 055 private void constructFields(EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime) 056 throws PersistenceNotNullException { 057 checkForNull(entityAttributePK); 058 this.entityAttributePK = entityAttributePK; 059 this.unitOfMeasureTypePK = unitOfMeasureTypePK; 060 checkForNull(fromTime); 061 this.fromTime = fromTime; 062 checkForNull(thruTime); 063 this.thruTime = thruTime; 064 } 065 066 /** Creates a new instance of EntityAttributeNumericValue */ 067 public EntityAttributeNumericValue(EntityAttributeNumericPK entityAttributeNumericPK, EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime) 068 throws PersistenceNotNullException { 069 super(entityAttributeNumericPK); 070 constructFields(entityAttributePK, unitOfMeasureTypePK, fromTime, thruTime); 071 } 072 073 /** Creates a new instance of EntityAttributeNumericValue */ 074 public EntityAttributeNumericValue(EntityAttributePK entityAttributePK, UnitOfMeasureTypePK unitOfMeasureTypePK, Long fromTime, Long thruTime) 075 throws PersistenceNotNullException { 076 super(); 077 constructFields(entityAttributePK, unitOfMeasureTypePK, fromTime, thruTime); 078 } 079 080 @Override 081 public EntityAttributeNumericFactory getBaseFactoryInstance() { 082 return EntityAttributeNumericFactory.getInstance(); 083 } 084 085 @Override 086 public EntityAttributeNumericValue 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 (EntityAttributeNumericValue)result; 097 } 098 099 @Override 100 public EntityAttributeNumericPK getPrimaryKey() { 101 if(_primaryKey == null) { 102 _primaryKey = new EntityAttributeNumericPK(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 + ((entityAttributePK != null) ? entityAttributePK.hashCode() : 0); 121 hashCode = 37 * hashCode + ((unitOfMeasureTypePK != null) ? unitOfMeasureTypePK.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 _stringValue = "{" + 135 "entityId=" + getEntityId() + 136 ", entityAttributePK=" + getEntityAttributePK() + 137 ", unitOfMeasureTypePK=" + getUnitOfMeasureTypePK() + 138 ", fromTime=" + getFromTime() + 139 ", thruTime=" + getThruTime() + 140 "}"; 141 } 142 return _stringValue; 143 } 144 145 @Override 146 public boolean equals(Object other) { 147 if(this == other) 148 return true; 149 150 if(!hasIdentity()) 151 return false; 152 153 if(other instanceof EntityAttributeNumericValue that) { 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 = isIdentical(that); 163 164 return objectsEqual; 165 } else { 166 return false; 167 } 168 } 169 170 public boolean isIdentical(Object other) { 171 if(other instanceof EntityAttributeNumericValue that) { 172 boolean objectsEqual = true; 173 174 175 if(objectsEqual) { 176 EntityAttributePK thisEntityAttributePK = getEntityAttributePK(); 177 EntityAttributePK thatEntityAttributePK = that.getEntityAttributePK(); 178 179 if(thisEntityAttributePK == null) { 180 objectsEqual = objectsEqual && (thatEntityAttributePK == null); 181 } else { 182 objectsEqual = objectsEqual && thisEntityAttributePK.equals(thatEntityAttributePK); 183 } 184 } 185 186 if(objectsEqual) { 187 UnitOfMeasureTypePK thisUnitOfMeasureTypePK = getUnitOfMeasureTypePK(); 188 UnitOfMeasureTypePK thatUnitOfMeasureTypePK = that.getUnitOfMeasureTypePK(); 189 190 if(thisUnitOfMeasureTypePK == null) { 191 objectsEqual = objectsEqual && (thatUnitOfMeasureTypePK == null); 192 } else { 193 objectsEqual = objectsEqual && thisUnitOfMeasureTypePK.equals(thatUnitOfMeasureTypePK); 194 } 195 } 196 197 if(objectsEqual) { 198 Long thisFromTime = getFromTime(); 199 Long thatFromTime = that.getFromTime(); 200 201 if(thisFromTime == null) { 202 objectsEqual = objectsEqual && (thatFromTime == null); 203 } else { 204 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 205 } 206 } 207 208 if(objectsEqual) { 209 Long thisThruTime = getThruTime(); 210 Long thatThruTime = that.getThruTime(); 211 212 if(thisThruTime == null) { 213 objectsEqual = objectsEqual && (thatThruTime == null); 214 } else { 215 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 216 } 217 } 218 219 return objectsEqual; 220 } else { 221 return false; 222 } 223 } 224 225 @Override 226 public boolean hasBeenModified() { 227 return entityAttributePKHasBeenModified || unitOfMeasureTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 228 } 229 230 @Override 231 public void clearHasBeenModified() { 232 entityAttributePKHasBeenModified = false; 233 unitOfMeasureTypePKHasBeenModified = false; 234 fromTimeHasBeenModified = false; 235 thruTimeHasBeenModified = false; 236 } 237 238 public EntityAttributePK getEntityAttributePK() { 239 return entityAttributePK; 240 } 241 242 public void setEntityAttributePK(EntityAttributePK entityAttributePK) 243 throws PersistenceNotNullException { 244 checkForNull(entityAttributePK); 245 246 boolean update = true; 247 248 if(this.entityAttributePK != null) { 249 if(this.entityAttributePK.equals(entityAttributePK)) { 250 update = false; 251 } 252 } else if(entityAttributePK == null) { 253 update = false; 254 } 255 256 if(update) { 257 this.entityAttributePK = entityAttributePK; 258 entityAttributePKHasBeenModified = true; 259 clearHashAndString(); 260 } 261 } 262 263 public boolean getEntityAttributePKHasBeenModified() { 264 return entityAttributePKHasBeenModified; 265 } 266 267 public UnitOfMeasureTypePK getUnitOfMeasureTypePK() { 268 return unitOfMeasureTypePK; 269 } 270 271 public void setUnitOfMeasureTypePK(UnitOfMeasureTypePK unitOfMeasureTypePK) { 272 boolean update = true; 273 274 if(this.unitOfMeasureTypePK != null) { 275 if(this.unitOfMeasureTypePK.equals(unitOfMeasureTypePK)) { 276 update = false; 277 } 278 } else if(unitOfMeasureTypePK == null) { 279 update = false; 280 } 281 282 if(update) { 283 this.unitOfMeasureTypePK = unitOfMeasureTypePK; 284 unitOfMeasureTypePKHasBeenModified = true; 285 clearHashAndString(); 286 } 287 } 288 289 public boolean getUnitOfMeasureTypePKHasBeenModified() { 290 return unitOfMeasureTypePKHasBeenModified; 291 } 292 293 public Long getFromTime() { 294 return fromTime; 295 } 296 297 public void setFromTime(Long fromTime) 298 throws PersistenceNotNullException { 299 checkForNull(fromTime); 300 301 boolean update = true; 302 303 if(this.fromTime != null) { 304 if(this.fromTime.equals(fromTime)) { 305 update = false; 306 } 307 } else if(fromTime == null) { 308 update = false; 309 } 310 311 if(update) { 312 this.fromTime = fromTime; 313 fromTimeHasBeenModified = true; 314 clearHashAndString(); 315 } 316 } 317 318 public boolean getFromTimeHasBeenModified() { 319 return fromTimeHasBeenModified; 320 } 321 322 public Long getThruTime() { 323 return thruTime; 324 } 325 326 public void setThruTime(Long thruTime) 327 throws PersistenceNotNullException { 328 checkForNull(thruTime); 329 330 boolean update = true; 331 332 if(this.thruTime != null) { 333 if(this.thruTime.equals(thruTime)) { 334 update = false; 335 } 336 } else if(thruTime == null) { 337 update = false; 338 } 339 340 if(update) { 341 this.thruTime = thruTime; 342 thruTimeHasBeenModified = true; 343 clearHashAndString(); 344 } 345 } 346 347 public boolean getThruTimeHasBeenModified() { 348 return thruTimeHasBeenModified; 349 } 350 351}