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 * EntityTimeValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.EntityTimePK; 026 027import com.echothree.model.data.core.server.factory.EntityTimeFactory; 028 029import com.echothree.model.data.core.common.pk.EntityInstancePK; 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 EntityTimeValue 042 extends BaseValue<EntityTimePK> 043 implements Cloneable, Serializable { 044 045 private EntityInstancePK entityInstancePK; 046 private boolean entityInstancePKHasBeenModified = false; 047 private Long createdTime; 048 private boolean createdTimeHasBeenModified = false; 049 private Long modifiedTime; 050 private boolean modifiedTimeHasBeenModified = false; 051 private Long deletedTime; 052 private boolean deletedTimeHasBeenModified = false; 053 054 private transient Integer _hashCode = null; 055 private transient String _stringValue = null; 056 057 private void constructFields(EntityInstancePK entityInstancePK, Long createdTime, Long modifiedTime, Long deletedTime) 058 throws PersistenceNotNullException { 059 checkForNull(entityInstancePK); 060 this.entityInstancePK = entityInstancePK; 061 checkForNull(createdTime); 062 this.createdTime = createdTime; 063 this.modifiedTime = modifiedTime; 064 this.deletedTime = deletedTime; 065 } 066 067 /** Creates a new instance of EntityTimeValue */ 068 public EntityTimeValue(EntityTimePK entityTimePK, EntityInstancePK entityInstancePK, Long createdTime, Long modifiedTime, Long deletedTime) 069 throws PersistenceNotNullException { 070 super(entityTimePK); 071 constructFields(entityInstancePK, createdTime, modifiedTime, deletedTime); 072 } 073 074 /** Creates a new instance of EntityTimeValue */ 075 public EntityTimeValue(EntityInstancePK entityInstancePK, Long createdTime, Long modifiedTime, Long deletedTime) 076 throws PersistenceNotNullException { 077 super(); 078 constructFields(entityInstancePK, createdTime, modifiedTime, deletedTime); 079 } 080 081 @Override 082 @Nonnull 083 public EntityTimeFactory getBaseFactoryInstance() { 084 return EntityTimeFactory.getInstance(); 085 } 086 087 @Override 088 @Nonnull 089 public EntityTimeValue clone() { 090 Object result; 091 092 try { 093 result = super.clone(); 094 } catch (CloneNotSupportedException cnse) { 095 // This shouldn't happen, fail when it does. 096 throw new PersistenceCloneException(cnse); 097 } 098 099 return (EntityTimeValue)result; 100 } 101 102 @Override 103 @Nonnull 104 public EntityTimePK getPrimaryKey() { 105 if(_primaryKey == null) { 106 _primaryKey = new EntityTimePK(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 + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0); 125 hashCode = 37 * hashCode + ((createdTime != null) ? createdTime.hashCode() : 0); 126 hashCode = 37 * hashCode + ((modifiedTime != null) ? modifiedTime.hashCode() : 0); 127 hashCode = 37 * hashCode + ((deletedTime != null) ? deletedTime.hashCode() : 0); 128 129 _hashCode = hashCode; 130 } 131 132 return _hashCode; 133 } 134 135 @Override 136 @Nonnull 137 public String toString() { 138 if(_stringValue == null) { 139 _stringValue = "{" + 140 "entityId=" + getEntityId() + 141 ", entityInstancePK=" + getEntityInstancePK() + 142 ", createdTime=" + getCreatedTime() + 143 ", modifiedTime=" + getModifiedTime() + 144 ", deletedTime=" + getDeletedTime() + 145 "}"; 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 EntityTimeValue that) { 159 if(!that.hasIdentity()) 160 return false; 161 162 Long thisEntityId = getEntityId(); 163 Long thatEntityId = that.getEntityId(); 164 165 boolean objectsEqual = thisEntityId.equals(thatEntityId); 166 if(objectsEqual) 167 objectsEqual = isIdentical(that); 168 169 return objectsEqual; 170 } else { 171 return false; 172 } 173 } 174 175 public boolean isIdentical(Object other) { 176 if(other instanceof EntityTimeValue that) { 177 boolean objectsEqual = true; 178 179 180 if(objectsEqual) { 181 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 182 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 183 184 if(thisEntityInstancePK == null) { 185 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 186 } else { 187 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 188 } 189 } 190 191 if(objectsEqual) { 192 Long thisCreatedTime = getCreatedTime(); 193 Long thatCreatedTime = that.getCreatedTime(); 194 195 if(thisCreatedTime == null) { 196 objectsEqual = objectsEqual && (thatCreatedTime == null); 197 } else { 198 objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime); 199 } 200 } 201 202 if(objectsEqual) { 203 Long thisModifiedTime = getModifiedTime(); 204 Long thatModifiedTime = that.getModifiedTime(); 205 206 if(thisModifiedTime == null) { 207 objectsEqual = objectsEqual && (thatModifiedTime == null); 208 } else { 209 objectsEqual = objectsEqual && thisModifiedTime.equals(thatModifiedTime); 210 } 211 } 212 213 if(objectsEqual) { 214 Long thisDeletedTime = getDeletedTime(); 215 Long thatDeletedTime = that.getDeletedTime(); 216 217 if(thisDeletedTime == null) { 218 objectsEqual = objectsEqual && (thatDeletedTime == null); 219 } else { 220 objectsEqual = objectsEqual && thisDeletedTime.equals(thatDeletedTime); 221 } 222 } 223 224 return objectsEqual; 225 } else { 226 return false; 227 } 228 } 229 230 @Override 231 public boolean hasBeenModified() { 232 return entityInstancePKHasBeenModified || createdTimeHasBeenModified || modifiedTimeHasBeenModified || deletedTimeHasBeenModified; 233 } 234 235 @Override 236 public void clearHasBeenModified() { 237 entityInstancePKHasBeenModified = false; 238 createdTimeHasBeenModified = false; 239 modifiedTimeHasBeenModified = false; 240 deletedTimeHasBeenModified = false; 241 } 242 243 @Nonnull 244 public EntityInstancePK getEntityInstancePK() { 245 return entityInstancePK; 246 } 247 248 public void setEntityInstancePK(@Nonnull EntityInstancePK entityInstancePK) 249 throws PersistenceNotNullException { 250 checkForNull(entityInstancePK); 251 252 boolean update = true; 253 254 if(this.entityInstancePK != null) { 255 if(this.entityInstancePK.equals(entityInstancePK)) { 256 update = false; 257 } 258 } else if(entityInstancePK == null) { 259 update = false; 260 } 261 262 if(update) { 263 this.entityInstancePK = entityInstancePK; 264 entityInstancePKHasBeenModified = true; 265 clearHashAndString(); 266 } 267 } 268 269 public boolean getEntityInstancePKHasBeenModified() { 270 return entityInstancePKHasBeenModified; 271 } 272 273 @Nonnull 274 public Long getCreatedTime() { 275 return createdTime; 276 } 277 278 public void setCreatedTime(@Nonnull Long createdTime) 279 throws PersistenceNotNullException { 280 checkForNull(createdTime); 281 282 boolean update = true; 283 284 if(this.createdTime != null) { 285 if(this.createdTime.equals(createdTime)) { 286 update = false; 287 } 288 } else if(createdTime == null) { 289 update = false; 290 } 291 292 if(update) { 293 this.createdTime = createdTime; 294 createdTimeHasBeenModified = true; 295 clearHashAndString(); 296 } 297 } 298 299 public boolean getCreatedTimeHasBeenModified() { 300 return createdTimeHasBeenModified; 301 } 302 303 @Nullable 304 public Long getModifiedTime() { 305 return modifiedTime; 306 } 307 308 public void setModifiedTime(@Nullable Long modifiedTime) { 309 boolean update = true; 310 311 if(this.modifiedTime != null) { 312 if(this.modifiedTime.equals(modifiedTime)) { 313 update = false; 314 } 315 } else if(modifiedTime == null) { 316 update = false; 317 } 318 319 if(update) { 320 this.modifiedTime = modifiedTime; 321 modifiedTimeHasBeenModified = true; 322 clearHashAndString(); 323 } 324 } 325 326 public boolean getModifiedTimeHasBeenModified() { 327 return modifiedTimeHasBeenModified; 328 } 329 330 @Nullable 331 public Long getDeletedTime() { 332 return deletedTime; 333 } 334 335 public void setDeletedTime(@Nullable Long deletedTime) { 336 boolean update = true; 337 338 if(this.deletedTime != null) { 339 if(this.deletedTime.equals(deletedTime)) { 340 update = false; 341 } 342 } else if(deletedTime == null) { 343 update = false; 344 } 345 346 if(update) { 347 this.deletedTime = deletedTime; 348 deletedTimeHasBeenModified = true; 349 clearHashAndString(); 350 } 351 } 352 353 public boolean getDeletedTimeHasBeenModified() { 354 return deletedTimeHasBeenModified; 355 } 356 357}