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