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 * CacheEntryValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.CacheEntryPK; 026 027import com.echothree.model.data.core.server.factory.CacheEntryFactory; 028 029import com.echothree.model.data.core.common.pk.MimeTypePK; 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 CacheEntryValue 042 extends BaseValue<CacheEntryPK> 043 implements Cloneable, Serializable { 044 045 private String cacheEntryKey; 046 private boolean cacheEntryKeyHasBeenModified = false; 047 private MimeTypePK mimeTypePK; 048 private boolean mimeTypePKHasBeenModified = false; 049 private Long createdTime; 050 private boolean createdTimeHasBeenModified = false; 051 private Long validUntilTime; 052 private boolean validUntilTimeHasBeenModified = false; 053 054 private transient Integer _hashCode = null; 055 private transient String _stringValue = null; 056 057 private void constructFields(String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 058 throws PersistenceNotNullException { 059 checkForNull(cacheEntryKey); 060 this.cacheEntryKey = cacheEntryKey; 061 checkForNull(mimeTypePK); 062 this.mimeTypePK = mimeTypePK; 063 checkForNull(createdTime); 064 this.createdTime = createdTime; 065 this.validUntilTime = validUntilTime; 066 } 067 068 /** Creates a new instance of CacheEntryValue */ 069 public CacheEntryValue(CacheEntryPK cacheEntryPK, String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 070 throws PersistenceNotNullException { 071 super(cacheEntryPK); 072 constructFields(cacheEntryKey, mimeTypePK, createdTime, validUntilTime); 073 } 074 075 /** Creates a new instance of CacheEntryValue */ 076 public CacheEntryValue(String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 077 throws PersistenceNotNullException { 078 super(); 079 constructFields(cacheEntryKey, mimeTypePK, createdTime, validUntilTime); 080 } 081 082 @Override 083 @Nonnull 084 public CacheEntryFactory getBaseFactoryInstance() { 085 return CacheEntryFactory.getInstance(); 086 } 087 088 @Override 089 @Nonnull 090 public CacheEntryValue 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 (CacheEntryValue)result; 101 } 102 103 @Override 104 @Nonnull 105 public CacheEntryPK getPrimaryKey() { 106 if(_primaryKey == null) { 107 _primaryKey = new CacheEntryPK(entityId); 108 } 109 110 return _primaryKey; 111 } 112 113 private void clearHashAndString() { 114 _hashCode = null; 115 _stringValue = null; 116 } 117 118 @Override 119 public int hashCode() { 120 if(_hashCode == null) { 121 int hashCode = 17; 122 123 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 124 125 hashCode = 37 * hashCode + ((cacheEntryKey != null) ? cacheEntryKey.hashCode() : 0); 126 hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0); 127 hashCode = 37 * hashCode + ((createdTime != null) ? createdTime.hashCode() : 0); 128 hashCode = 37 * hashCode + ((validUntilTime != null) ? validUntilTime.hashCode() : 0); 129 130 _hashCode = hashCode; 131 } 132 133 return _hashCode; 134 } 135 136 @Override 137 @Nonnull 138 public String toString() { 139 if(_stringValue == null) { 140 _stringValue = "{" + 141 "entityId=" + getEntityId() + 142 ", cacheEntryKey=" + getCacheEntryKey() + 143 ", mimeTypePK=" + getMimeTypePK() + 144 ", createdTime=" + getCreatedTime() + 145 ", validUntilTime=" + getValidUntilTime() + 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 CacheEntryValue 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 CacheEntryValue that) { 178 boolean objectsEqual = true; 179 180 181 if(objectsEqual) { 182 String thisCacheEntryKey = getCacheEntryKey(); 183 String thatCacheEntryKey = that.getCacheEntryKey(); 184 185 if(thisCacheEntryKey == null) { 186 objectsEqual = objectsEqual && (thatCacheEntryKey == null); 187 } else { 188 objectsEqual = objectsEqual && thisCacheEntryKey.equals(thatCacheEntryKey); 189 } 190 } 191 192 if(objectsEqual) { 193 MimeTypePK thisMimeTypePK = getMimeTypePK(); 194 MimeTypePK thatMimeTypePK = that.getMimeTypePK(); 195 196 if(thisMimeTypePK == null) { 197 objectsEqual = objectsEqual && (thatMimeTypePK == null); 198 } else { 199 objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK); 200 } 201 } 202 203 if(objectsEqual) { 204 Long thisCreatedTime = getCreatedTime(); 205 Long thatCreatedTime = that.getCreatedTime(); 206 207 if(thisCreatedTime == null) { 208 objectsEqual = objectsEqual && (thatCreatedTime == null); 209 } else { 210 objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime); 211 } 212 } 213 214 if(objectsEqual) { 215 Long thisValidUntilTime = getValidUntilTime(); 216 Long thatValidUntilTime = that.getValidUntilTime(); 217 218 if(thisValidUntilTime == null) { 219 objectsEqual = objectsEqual && (thatValidUntilTime == null); 220 } else { 221 objectsEqual = objectsEqual && thisValidUntilTime.equals(thatValidUntilTime); 222 } 223 } 224 225 return objectsEqual; 226 } else { 227 return false; 228 } 229 } 230 231 @Override 232 public boolean hasBeenModified() { 233 return cacheEntryKeyHasBeenModified || mimeTypePKHasBeenModified || createdTimeHasBeenModified || validUntilTimeHasBeenModified; 234 } 235 236 @Override 237 public void clearHasBeenModified() { 238 cacheEntryKeyHasBeenModified = false; 239 mimeTypePKHasBeenModified = false; 240 createdTimeHasBeenModified = false; 241 validUntilTimeHasBeenModified = false; 242 } 243 244 @Nonnull 245 public String getCacheEntryKey() { 246 return cacheEntryKey; 247 } 248 249 public void setCacheEntryKey(@Nonnull String cacheEntryKey) 250 throws PersistenceNotNullException { 251 checkForNull(cacheEntryKey); 252 253 boolean update = true; 254 255 if(this.cacheEntryKey != null) { 256 if(this.cacheEntryKey.equals(cacheEntryKey)) { 257 update = false; 258 } 259 } else if(cacheEntryKey == null) { 260 update = false; 261 } 262 263 if(update) { 264 this.cacheEntryKey = cacheEntryKey; 265 cacheEntryKeyHasBeenModified = true; 266 clearHashAndString(); 267 } 268 } 269 270 public boolean getCacheEntryKeyHasBeenModified() { 271 return cacheEntryKeyHasBeenModified; 272 } 273 274 @Nonnull 275 public MimeTypePK getMimeTypePK() { 276 return mimeTypePK; 277 } 278 279 public void setMimeTypePK(@Nonnull MimeTypePK mimeTypePK) 280 throws PersistenceNotNullException { 281 checkForNull(mimeTypePK); 282 283 boolean update = true; 284 285 if(this.mimeTypePK != null) { 286 if(this.mimeTypePK.equals(mimeTypePK)) { 287 update = false; 288 } 289 } else if(mimeTypePK == null) { 290 update = false; 291 } 292 293 if(update) { 294 this.mimeTypePK = mimeTypePK; 295 mimeTypePKHasBeenModified = true; 296 clearHashAndString(); 297 } 298 } 299 300 public boolean getMimeTypePKHasBeenModified() { 301 return mimeTypePKHasBeenModified; 302 } 303 304 @Nonnull 305 public Long getCreatedTime() { 306 return createdTime; 307 } 308 309 public void setCreatedTime(@Nonnull Long createdTime) 310 throws PersistenceNotNullException { 311 checkForNull(createdTime); 312 313 boolean update = true; 314 315 if(this.createdTime != null) { 316 if(this.createdTime.equals(createdTime)) { 317 update = false; 318 } 319 } else if(createdTime == null) { 320 update = false; 321 } 322 323 if(update) { 324 this.createdTime = createdTime; 325 createdTimeHasBeenModified = true; 326 clearHashAndString(); 327 } 328 } 329 330 public boolean getCreatedTimeHasBeenModified() { 331 return createdTimeHasBeenModified; 332 } 333 334 @Nullable 335 public Long getValidUntilTime() { 336 return validUntilTime; 337 } 338 339 public void setValidUntilTime(@Nullable Long validUntilTime) { 340 boolean update = true; 341 342 if(this.validUntilTime != null) { 343 if(this.validUntilTime.equals(validUntilTime)) { 344 update = false; 345 } 346 } else if(validUntilTime == null) { 347 update = false; 348 } 349 350 if(update) { 351 this.validUntilTime = validUntilTime; 352 validUntilTimeHasBeenModified = true; 353 clearHashAndString(); 354 } 355 } 356 357 public boolean getValidUntilTimeHasBeenModified() { 358 return validUntilTimeHasBeenModified; 359 } 360 361}