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 * EntityEncryptionKeyValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.EntityEncryptionKeyPK; 026 027import com.echothree.model.data.core.server.factory.EntityEncryptionKeyFactory; 028 029import com.echothree.util.common.exception.PersistenceCloneException; 030import com.echothree.util.common.exception.PersistenceNotNullException; 031 032import com.echothree.util.server.persistence.BaseValue; 033 034import java.io.Serializable; 035 036import javax.annotation.Nonnull; 037import javax.annotation.Nullable; 038 039public class EntityEncryptionKeyValue 040 extends BaseValue<EntityEncryptionKeyPK> 041 implements Cloneable, Serializable { 042 043 private String entityEncryptionKeyName; 044 private boolean entityEncryptionKeyNameHasBeenModified = false; 045 private Boolean isExternal; 046 private boolean isExternalHasBeenModified = false; 047 private String secretKey; 048 private boolean secretKeyHasBeenModified = false; 049 private String initializationVector; 050 private boolean initializationVectorHasBeenModified = false; 051 052 private transient Integer _hashCode = null; 053 private transient String _stringValue = null; 054 055 private void constructFields(String entityEncryptionKeyName, Boolean isExternal, String secretKey, String initializationVector) 056 throws PersistenceNotNullException { 057 checkForNull(entityEncryptionKeyName); 058 this.entityEncryptionKeyName = entityEncryptionKeyName; 059 checkForNull(isExternal); 060 this.isExternal = isExternal; 061 checkForNull(secretKey); 062 this.secretKey = secretKey; 063 checkForNull(initializationVector); 064 this.initializationVector = initializationVector; 065 } 066 067 /** Creates a new instance of EntityEncryptionKeyValue */ 068 public EntityEncryptionKeyValue(EntityEncryptionKeyPK entityEncryptionKeyPK, String entityEncryptionKeyName, Boolean isExternal, String secretKey, String initializationVector) 069 throws PersistenceNotNullException { 070 super(entityEncryptionKeyPK); 071 constructFields(entityEncryptionKeyName, isExternal, secretKey, initializationVector); 072 } 073 074 /** Creates a new instance of EntityEncryptionKeyValue */ 075 public EntityEncryptionKeyValue(String entityEncryptionKeyName, Boolean isExternal, String secretKey, String initializationVector) 076 throws PersistenceNotNullException { 077 super(); 078 constructFields(entityEncryptionKeyName, isExternal, secretKey, initializationVector); 079 } 080 081 @Override 082 @Nonnull 083 public EntityEncryptionKeyFactory getBaseFactoryInstance() { 084 return EntityEncryptionKeyFactory.getInstance(); 085 } 086 087 @Override 088 @Nonnull 089 public EntityEncryptionKeyValue 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 (EntityEncryptionKeyValue)result; 100 } 101 102 @Override 103 @Nonnull 104 public EntityEncryptionKeyPK getPrimaryKey() { 105 if(_primaryKey == null) { 106 _primaryKey = new EntityEncryptionKeyPK(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 + ((entityEncryptionKeyName != null) ? entityEncryptionKeyName.hashCode() : 0); 125 hashCode = 37 * hashCode + ((isExternal != null) ? isExternal.hashCode() : 0); 126 hashCode = 37 * hashCode + ((secretKey != null) ? secretKey.hashCode() : 0); 127 hashCode = 37 * hashCode + ((initializationVector != null) ? initializationVector.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 ", entityEncryptionKeyName=" + getEntityEncryptionKeyName() + 142 ", isExternal=" + getIsExternal() + 143 ", secretKey=" + getSecretKey() + 144 ", initializationVector=" + getInitializationVector() + 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 EntityEncryptionKeyValue 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 EntityEncryptionKeyValue that) { 177 boolean objectsEqual = true; 178 179 180 if(objectsEqual) { 181 String thisEntityEncryptionKeyName = getEntityEncryptionKeyName(); 182 String thatEntityEncryptionKeyName = that.getEntityEncryptionKeyName(); 183 184 if(thisEntityEncryptionKeyName == null) { 185 objectsEqual = objectsEqual && (thatEntityEncryptionKeyName == null); 186 } else { 187 objectsEqual = objectsEqual && thisEntityEncryptionKeyName.equals(thatEntityEncryptionKeyName); 188 } 189 } 190 191 if(objectsEqual) { 192 Boolean thisIsExternal = getIsExternal(); 193 Boolean thatIsExternal = that.getIsExternal(); 194 195 if(thisIsExternal == null) { 196 objectsEqual = objectsEqual && (thatIsExternal == null); 197 } else { 198 objectsEqual = objectsEqual && thisIsExternal.equals(thatIsExternal); 199 } 200 } 201 202 if(objectsEqual) { 203 String thisSecretKey = getSecretKey(); 204 String thatSecretKey = that.getSecretKey(); 205 206 if(thisSecretKey == null) { 207 objectsEqual = objectsEqual && (thatSecretKey == null); 208 } else { 209 objectsEqual = objectsEqual && thisSecretKey.equals(thatSecretKey); 210 } 211 } 212 213 if(objectsEqual) { 214 String thisInitializationVector = getInitializationVector(); 215 String thatInitializationVector = that.getInitializationVector(); 216 217 if(thisInitializationVector == null) { 218 objectsEqual = objectsEqual && (thatInitializationVector == null); 219 } else { 220 objectsEqual = objectsEqual && thisInitializationVector.equals(thatInitializationVector); 221 } 222 } 223 224 return objectsEqual; 225 } else { 226 return false; 227 } 228 } 229 230 @Override 231 public boolean hasBeenModified() { 232 return entityEncryptionKeyNameHasBeenModified || isExternalHasBeenModified || secretKeyHasBeenModified || initializationVectorHasBeenModified; 233 } 234 235 @Override 236 public void clearHasBeenModified() { 237 entityEncryptionKeyNameHasBeenModified = false; 238 isExternalHasBeenModified = false; 239 secretKeyHasBeenModified = false; 240 initializationVectorHasBeenModified = false; 241 } 242 243 @Nonnull 244 public String getEntityEncryptionKeyName() { 245 return entityEncryptionKeyName; 246 } 247 248 public void setEntityEncryptionKeyName(@Nonnull String entityEncryptionKeyName) 249 throws PersistenceNotNullException { 250 checkForNull(entityEncryptionKeyName); 251 252 boolean update = true; 253 254 if(this.entityEncryptionKeyName != null) { 255 if(this.entityEncryptionKeyName.equals(entityEncryptionKeyName)) { 256 update = false; 257 } 258 } else if(entityEncryptionKeyName == null) { 259 update = false; 260 } 261 262 if(update) { 263 this.entityEncryptionKeyName = entityEncryptionKeyName; 264 entityEncryptionKeyNameHasBeenModified = true; 265 clearHashAndString(); 266 } 267 } 268 269 public boolean getEntityEncryptionKeyNameHasBeenModified() { 270 return entityEncryptionKeyNameHasBeenModified; 271 } 272 273 @Nonnull 274 public Boolean getIsExternal() { 275 return isExternal; 276 } 277 278 public void setIsExternal(@Nonnull Boolean isExternal) 279 throws PersistenceNotNullException { 280 checkForNull(isExternal); 281 282 boolean update = true; 283 284 if(this.isExternal != null) { 285 if(this.isExternal.equals(isExternal)) { 286 update = false; 287 } 288 } else if(isExternal == null) { 289 update = false; 290 } 291 292 if(update) { 293 this.isExternal = isExternal; 294 isExternalHasBeenModified = true; 295 clearHashAndString(); 296 } 297 } 298 299 public boolean getIsExternalHasBeenModified() { 300 return isExternalHasBeenModified; 301 } 302 303 @Nonnull 304 public String getSecretKey() { 305 return secretKey; 306 } 307 308 public void setSecretKey(@Nonnull String secretKey) 309 throws PersistenceNotNullException { 310 checkForNull(secretKey); 311 312 boolean update = true; 313 314 if(this.secretKey != null) { 315 if(this.secretKey.equals(secretKey)) { 316 update = false; 317 } 318 } else if(secretKey == null) { 319 update = false; 320 } 321 322 if(update) { 323 this.secretKey = secretKey; 324 secretKeyHasBeenModified = true; 325 clearHashAndString(); 326 } 327 } 328 329 public boolean getSecretKeyHasBeenModified() { 330 return secretKeyHasBeenModified; 331 } 332 333 @Nonnull 334 public String getInitializationVector() { 335 return initializationVector; 336 } 337 338 public void setInitializationVector(@Nonnull String initializationVector) 339 throws PersistenceNotNullException { 340 checkForNull(initializationVector); 341 342 boolean update = true; 343 344 if(this.initializationVector != null) { 345 if(this.initializationVector.equals(initializationVector)) { 346 update = false; 347 } 348 } else if(initializationVector == null) { 349 update = false; 350 } 351 352 if(update) { 353 this.initializationVector = initializationVector; 354 initializationVectorHasBeenModified = true; 355 clearHashAndString(); 356 } 357 } 358 359 public boolean getInitializationVectorHasBeenModified() { 360 return initializationVectorHasBeenModified; 361 } 362 363}