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 * 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 038public class CacheEntryValue 039 extends BaseValue<CacheEntryPK> 040 implements Cloneable, Serializable { 041 042 private String cacheEntryKey; 043 private boolean cacheEntryKeyHasBeenModified = false; 044 private MimeTypePK mimeTypePK; 045 private boolean mimeTypePKHasBeenModified = false; 046 private Long createdTime; 047 private boolean createdTimeHasBeenModified = false; 048 private Long validUntilTime; 049 private boolean validUntilTimeHasBeenModified = false; 050 051 private transient Integer _hashCode = null; 052 private transient String _stringValue = null; 053 054 private void constructFields(String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 055 throws PersistenceNotNullException { 056 checkForNull(cacheEntryKey); 057 this.cacheEntryKey = cacheEntryKey; 058 checkForNull(mimeTypePK); 059 this.mimeTypePK = mimeTypePK; 060 checkForNull(createdTime); 061 this.createdTime = createdTime; 062 this.validUntilTime = validUntilTime; 063 } 064 065 /** Creates a new instance of CacheEntryValue */ 066 public CacheEntryValue(CacheEntryPK cacheEntryPK, String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 067 throws PersistenceNotNullException { 068 super(cacheEntryPK); 069 constructFields(cacheEntryKey, mimeTypePK, createdTime, validUntilTime); 070 } 071 072 /** Creates a new instance of CacheEntryValue */ 073 public CacheEntryValue(String cacheEntryKey, MimeTypePK mimeTypePK, Long createdTime, Long validUntilTime) 074 throws PersistenceNotNullException { 075 super(); 076 constructFields(cacheEntryKey, mimeTypePK, createdTime, validUntilTime); 077 } 078 079 @Override 080 public CacheEntryFactory getBaseFactoryInstance() { 081 return CacheEntryFactory.getInstance(); 082 } 083 084 @Override 085 public CacheEntryValue 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 (CacheEntryValue)result; 096 } 097 098 @Override 099 public CacheEntryPK getPrimaryKey() { 100 if(_primaryKey == null) { 101 _primaryKey = new CacheEntryPK(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 + ((cacheEntryKey != null) ? cacheEntryKey.hashCode() : 0); 120 hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0); 121 hashCode = 37 * hashCode + ((createdTime != null) ? createdTime.hashCode() : 0); 122 hashCode = 37 * hashCode + ((validUntilTime != null) ? validUntilTime.hashCode() : 0); 123 124 _hashCode = hashCode; 125 } 126 127 return _hashCode; 128 } 129 130 @Override 131 public String toString() { 132 if(_stringValue == null) { 133 _stringValue = "{" + 134 "entityId=" + getEntityId() + 135 ", cacheEntryKey=" + getCacheEntryKey() + 136 ", mimeTypePK=" + getMimeTypePK() + 137 ", createdTime=" + getCreatedTime() + 138 ", validUntilTime=" + getValidUntilTime() + 139 "}"; 140 } 141 return _stringValue; 142 } 143 144 @Override 145 public boolean equals(Object other) { 146 if(this == other) 147 return true; 148 149 if(!hasIdentity()) 150 return false; 151 152 if(other instanceof CacheEntryValue that) { 153 if(!that.hasIdentity()) 154 return false; 155 156 Long thisEntityId = getEntityId(); 157 Long thatEntityId = that.getEntityId(); 158 159 boolean objectsEqual = thisEntityId.equals(thatEntityId); 160 if(objectsEqual) 161 objectsEqual = isIdentical(that); 162 163 return objectsEqual; 164 } else { 165 return false; 166 } 167 } 168 169 public boolean isIdentical(Object other) { 170 if(other instanceof CacheEntryValue that) { 171 boolean objectsEqual = true; 172 173 174 if(objectsEqual) { 175 String thisCacheEntryKey = getCacheEntryKey(); 176 String thatCacheEntryKey = that.getCacheEntryKey(); 177 178 if(thisCacheEntryKey == null) { 179 objectsEqual = objectsEqual && (thatCacheEntryKey == null); 180 } else { 181 objectsEqual = objectsEqual && thisCacheEntryKey.equals(thatCacheEntryKey); 182 } 183 } 184 185 if(objectsEqual) { 186 MimeTypePK thisMimeTypePK = getMimeTypePK(); 187 MimeTypePK thatMimeTypePK = that.getMimeTypePK(); 188 189 if(thisMimeTypePK == null) { 190 objectsEqual = objectsEqual && (thatMimeTypePK == null); 191 } else { 192 objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK); 193 } 194 } 195 196 if(objectsEqual) { 197 Long thisCreatedTime = getCreatedTime(); 198 Long thatCreatedTime = that.getCreatedTime(); 199 200 if(thisCreatedTime == null) { 201 objectsEqual = objectsEqual && (thatCreatedTime == null); 202 } else { 203 objectsEqual = objectsEqual && thisCreatedTime.equals(thatCreatedTime); 204 } 205 } 206 207 if(objectsEqual) { 208 Long thisValidUntilTime = getValidUntilTime(); 209 Long thatValidUntilTime = that.getValidUntilTime(); 210 211 if(thisValidUntilTime == null) { 212 objectsEqual = objectsEqual && (thatValidUntilTime == null); 213 } else { 214 objectsEqual = objectsEqual && thisValidUntilTime.equals(thatValidUntilTime); 215 } 216 } 217 218 return objectsEqual; 219 } else { 220 return false; 221 } 222 } 223 224 @Override 225 public boolean hasBeenModified() { 226 return cacheEntryKeyHasBeenModified || mimeTypePKHasBeenModified || createdTimeHasBeenModified || validUntilTimeHasBeenModified; 227 } 228 229 @Override 230 public void clearHasBeenModified() { 231 cacheEntryKeyHasBeenModified = false; 232 mimeTypePKHasBeenModified = false; 233 createdTimeHasBeenModified = false; 234 validUntilTimeHasBeenModified = false; 235 } 236 237 public String getCacheEntryKey() { 238 return cacheEntryKey; 239 } 240 241 public void setCacheEntryKey(String cacheEntryKey) 242 throws PersistenceNotNullException { 243 checkForNull(cacheEntryKey); 244 245 boolean update = true; 246 247 if(this.cacheEntryKey != null) { 248 if(this.cacheEntryKey.equals(cacheEntryKey)) { 249 update = false; 250 } 251 } else if(cacheEntryKey == null) { 252 update = false; 253 } 254 255 if(update) { 256 this.cacheEntryKey = cacheEntryKey; 257 cacheEntryKeyHasBeenModified = true; 258 clearHashAndString(); 259 } 260 } 261 262 public boolean getCacheEntryKeyHasBeenModified() { 263 return cacheEntryKeyHasBeenModified; 264 } 265 266 public MimeTypePK getMimeTypePK() { 267 return mimeTypePK; 268 } 269 270 public void setMimeTypePK(MimeTypePK mimeTypePK) 271 throws PersistenceNotNullException { 272 checkForNull(mimeTypePK); 273 274 boolean update = true; 275 276 if(this.mimeTypePK != null) { 277 if(this.mimeTypePK.equals(mimeTypePK)) { 278 update = false; 279 } 280 } else if(mimeTypePK == null) { 281 update = false; 282 } 283 284 if(update) { 285 this.mimeTypePK = mimeTypePK; 286 mimeTypePKHasBeenModified = true; 287 clearHashAndString(); 288 } 289 } 290 291 public boolean getMimeTypePKHasBeenModified() { 292 return mimeTypePKHasBeenModified; 293 } 294 295 public Long getCreatedTime() { 296 return createdTime; 297 } 298 299 public void setCreatedTime(Long createdTime) 300 throws PersistenceNotNullException { 301 checkForNull(createdTime); 302 303 boolean update = true; 304 305 if(this.createdTime != null) { 306 if(this.createdTime.equals(createdTime)) { 307 update = false; 308 } 309 } else if(createdTime == null) { 310 update = false; 311 } 312 313 if(update) { 314 this.createdTime = createdTime; 315 createdTimeHasBeenModified = true; 316 clearHashAndString(); 317 } 318 } 319 320 public boolean getCreatedTimeHasBeenModified() { 321 return createdTimeHasBeenModified; 322 } 323 324 public Long getValidUntilTime() { 325 return validUntilTime; 326 } 327 328 public void setValidUntilTime(Long validUntilTime) { 329 boolean update = true; 330 331 if(this.validUntilTime != null) { 332 if(this.validUntilTime.equals(validUntilTime)) { 333 update = false; 334 } 335 } else if(validUntilTime == null) { 336 update = false; 337 } 338 339 if(update) { 340 this.validUntilTime = validUntilTime; 341 validUntilTimeHasBeenModified = true; 342 clearHashAndString(); 343 } 344 } 345 346 public boolean getValidUntilTimeHasBeenModified() { 347 return validUntilTimeHasBeenModified; 348 } 349 350}