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 * EntityEncryptionKey.java 021 */ 022 023package com.echothree.model.data.core.server.entity; 024 025import com.echothree.model.data.core.common.pk.EntityEncryptionKeyPK; 026 027import com.echothree.model.data.core.common.pk.EntityEncryptionKeyPK; 028 029import com.echothree.model.data.core.server.value.EntityEncryptionKeyValue; 030 031import com.echothree.model.data.core.server.factory.EntityEncryptionKeyFactory; 032 033import com.echothree.util.common.exception.PersistenceException; 034import com.echothree.util.common.exception.PersistenceDatabaseException; 035import com.echothree.util.common.exception.PersistenceNotNullException; 036import com.echothree.util.common.exception.PersistenceReadOnlyException; 037 038import com.echothree.util.common.persistence.BasePK; 039 040import com.echothree.util.common.persistence.type.ByteArray; 041 042import com.echothree.util.server.persistence.BaseEntity; 043import com.echothree.util.server.persistence.EntityPermission; 044import com.echothree.util.server.persistence.Session; 045import com.echothree.util.server.persistence.ThreadSession; 046 047import java.io.Serializable; 048 049import javax.annotation.Nonnull; 050import javax.annotation.Nullable; 051 052public class EntityEncryptionKey 053 extends BaseEntity 054 implements Serializable { 055 056 private EntityEncryptionKeyPK _pk; 057 private EntityEncryptionKeyValue _value; 058 059 /** Creates a new instance of EntityEncryptionKey */ 060 public EntityEncryptionKey() 061 throws PersistenceException { 062 super(); 063 } 064 065 /** Creates a new instance of EntityEncryptionKey */ 066 public EntityEncryptionKey(EntityEncryptionKeyValue value, EntityPermission entityPermission) { 067 super(entityPermission); 068 069 _value = value; 070 _pk = value.getPrimaryKey(); 071 } 072 073 @Override 074 @Nonnull 075 public EntityEncryptionKeyFactory getBaseFactoryInstance() { 076 return EntityEncryptionKeyFactory.getInstance(); 077 } 078 079 @Override 080 public boolean hasBeenModified() { 081 return _value.hasBeenModified(); 082 } 083 084 @Override 085 public int hashCode() { 086 return _pk.hashCode(); 087 } 088 089 @Override 090 @Nonnull 091 public String toString() { 092 return _pk.toString(); 093 } 094 095 @Override 096 public boolean equals(Object other) { 097 if(this == other) 098 return true; 099 100 if(other instanceof EntityEncryptionKey that) { 101 EntityEncryptionKeyValue thatValue = that.getEntityEncryptionKeyValue(); 102 return _value.equals(thatValue); 103 } else { 104 return false; 105 } 106 } 107 108 @Override 109 public void store() 110 throws PersistenceDatabaseException { 111 getBaseFactoryInstance().store(this); 112 } 113 114 @Override 115 public void remove() 116 throws PersistenceDatabaseException { 117 getBaseFactoryInstance().remove(this); 118 } 119 120 @Nonnull 121 public EntityEncryptionKeyValue getEntityEncryptionKeyValue() { 122 return _value; 123 } 124 125 public void setEntityEncryptionKeyValue(@Nonnull EntityEncryptionKeyValue value) 126 throws PersistenceReadOnlyException { 127 checkReadWrite(); 128 _value = value; 129 } 130 131 @Override 132 @Nonnull 133 public EntityEncryptionKeyPK getPrimaryKey() { 134 return _pk; 135 } 136 137 @Nonnull 138 public String getEntityEncryptionKeyNameHash() { 139 return _value.getEntityEncryptionKeyNameHash(); 140 } 141 142 public void setEntityEncryptionKeyNameHash(@Nonnull String entityEncryptionKeyNameHash) 143 throws PersistenceNotNullException, PersistenceReadOnlyException { 144 checkReadWrite(); 145 _value.setEntityEncryptionKeyNameHash(entityEncryptionKeyNameHash); 146 } 147 148 public boolean getEntityEncryptionKeyNameHashHasBeenModified() { 149 return _value.getEntityEncryptionKeyNameHashHasBeenModified(); 150 } 151 152 @Nonnull 153 public String getSecretKey() { 154 return _value.getSecretKey(); 155 } 156 157 public void setSecretKey(@Nonnull String secretKey) 158 throws PersistenceNotNullException, PersistenceReadOnlyException { 159 checkReadWrite(); 160 _value.setSecretKey(secretKey); 161 } 162 163 public boolean getSecretKeyHasBeenModified() { 164 return _value.getSecretKeyHasBeenModified(); 165 } 166 167}