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