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