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 * 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
049public class EntityEncryptionKey
050        extends BaseEntity
051        implements Serializable {
052    
053    private EntityEncryptionKeyPK _pk;
054    private EntityEncryptionKeyValue _value;
055    
056    /** Creates a new instance of EntityEncryptionKey */
057    public EntityEncryptionKey()
058            throws PersistenceException {
059        super();
060    }
061    
062    /** Creates a new instance of EntityEncryptionKey */
063    public EntityEncryptionKey(EntityEncryptionKeyValue value, EntityPermission entityPermission) {
064        super(entityPermission);
065        
066        _value = value;
067        _pk = value.getPrimaryKey();
068    }
069    
070    @Override
071    public EntityEncryptionKeyFactory getBaseFactoryInstance() {
072        return EntityEncryptionKeyFactory.getInstance();
073    }
074    
075    @Override
076    public boolean hasBeenModified() {
077        return _value.hasBeenModified();
078    }
079    
080    @Override
081    public int hashCode() {
082        return _pk.hashCode();
083    }
084    
085    @Override
086    public String toString() {
087        return _pk.toString();
088    }
089    
090    @Override
091    public boolean equals(Object other) {
092        if(this == other)
093            return true;
094        
095        if(other instanceof EntityEncryptionKey) {
096            EntityEncryptionKey that = (EntityEncryptionKey)other;
097            
098            EntityEncryptionKeyValue thatValue = that.getEntityEncryptionKeyValue();
099            return _value.equals(thatValue);
100        } else {
101            return false;
102        }
103    }
104    
105    @Override
106    public void store(Session session)
107            throws PersistenceDatabaseException {
108        getBaseFactoryInstance().store(session, this);
109    }
110    
111    @Override
112    public void remove(Session session)
113            throws PersistenceDatabaseException {
114        getBaseFactoryInstance().remove(session, this);
115    }
116    
117    @Override
118    public void remove()
119            throws PersistenceDatabaseException {
120        getBaseFactoryInstance().remove(ThreadSession.currentSession(), this);
121    }
122    
123    public EntityEncryptionKeyValue getEntityEncryptionKeyValue() {
124        return _value;
125    }
126    
127    public void setEntityEncryptionKeyValue(EntityEncryptionKeyValue value)
128            throws PersistenceReadOnlyException {
129        checkReadWrite();
130        _value = value;
131    }
132    
133    @Override
134    public EntityEncryptionKeyPK getPrimaryKey() {
135        return _pk;
136    }
137    
138    public String getEntityEncryptionKeyName() {
139        return _value.getEntityEncryptionKeyName();
140    }
141    
142    public void setEntityEncryptionKeyName(String entityEncryptionKeyName)
143            throws PersistenceNotNullException, PersistenceReadOnlyException {
144        checkReadWrite();
145        _value.setEntityEncryptionKeyName(entityEncryptionKeyName);
146    }
147    
148    public boolean getEntityEncryptionKeyNameHasBeenModified() {
149        return _value.getEntityEncryptionKeyNameHasBeenModified();
150    }
151    
152    public Boolean getIsExternal() {
153        return _value.getIsExternal();
154    }
155    
156    public void setIsExternal(Boolean isExternal)
157            throws PersistenceNotNullException, PersistenceReadOnlyException {
158        checkReadWrite();
159        _value.setIsExternal(isExternal);
160    }
161    
162    public boolean getIsExternalHasBeenModified() {
163        return _value.getIsExternalHasBeenModified();
164    }
165    
166    public String getSecretKey() {
167        return _value.getSecretKey();
168    }
169    
170    public void setSecretKey(String secretKey)
171            throws PersistenceNotNullException, PersistenceReadOnlyException {
172        checkReadWrite();
173        _value.setSecretKey(secretKey);
174    }
175    
176    public boolean getSecretKeyHasBeenModified() {
177        return _value.getSecretKeyHasBeenModified();
178    }
179    
180    public String getInitializationVector() {
181        return _value.getInitializationVector();
182    }
183    
184    public void setInitializationVector(String initializationVector)
185            throws PersistenceNotNullException, PersistenceReadOnlyException {
186        checkReadWrite();
187        _value.setInitializationVector(initializationVector);
188    }
189    
190    public boolean getInitializationVectorHasBeenModified() {
191        return _value.getInitializationVectorHasBeenModified();
192    }
193    
194}