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 * CacheEntryDependency.java
021 */
022
023package com.echothree.model.data.core.server.entity;
024
025import com.echothree.model.data.core.common.pk.CacheEntryDependencyPK;
026
027import com.echothree.model.data.core.common.pk.CacheEntryPK;
028import com.echothree.model.data.core.common.pk.EntityInstancePK;
029
030import com.echothree.model.data.core.server.entity.CacheEntry;
031import com.echothree.model.data.core.server.entity.EntityInstance;
032
033import com.echothree.model.data.core.server.factory.CacheEntryFactory;
034import com.echothree.model.data.core.server.factory.EntityInstanceFactory;
035
036import com.echothree.model.data.core.common.pk.CacheEntryDependencyPK;
037
038import com.echothree.model.data.core.server.value.CacheEntryDependencyValue;
039
040import com.echothree.model.data.core.server.factory.CacheEntryDependencyFactory;
041
042import com.echothree.util.common.exception.PersistenceException;
043import com.echothree.util.common.exception.PersistenceDatabaseException;
044import com.echothree.util.common.exception.PersistenceNotNullException;
045import com.echothree.util.common.exception.PersistenceReadOnlyException;
046
047import com.echothree.util.common.persistence.BasePK;
048
049import com.echothree.util.common.persistence.type.ByteArray;
050
051import com.echothree.util.server.persistence.BaseEntity;
052import com.echothree.util.server.persistence.EntityPermission;
053import com.echothree.util.server.persistence.Session;
054import com.echothree.util.server.persistence.ThreadSession;
055
056import java.io.Serializable;
057
058public class CacheEntryDependency
059        extends BaseEntity
060        implements Serializable {
061    
062    private CacheEntryDependencyPK _pk;
063    private CacheEntryDependencyValue _value;
064    
065    /** Creates a new instance of CacheEntryDependency */
066    public CacheEntryDependency()
067            throws PersistenceException {
068        super();
069    }
070    
071    /** Creates a new instance of CacheEntryDependency */
072    public CacheEntryDependency(CacheEntryDependencyValue value, EntityPermission entityPermission) {
073        super(entityPermission);
074        
075        _value = value;
076        _pk = value.getPrimaryKey();
077    }
078    
079    @Override
080    public CacheEntryDependencyFactory getBaseFactoryInstance() {
081        return CacheEntryDependencyFactory.getInstance();
082    }
083    
084    @Override
085    public boolean hasBeenModified() {
086        return _value.hasBeenModified();
087    }
088    
089    @Override
090    public int hashCode() {
091        return _pk.hashCode();
092    }
093    
094    @Override
095    public String toString() {
096        return _pk.toString();
097    }
098    
099    @Override
100    public boolean equals(Object other) {
101        if(this == other)
102            return true;
103        
104        if(other instanceof CacheEntryDependency that) {
105            CacheEntryDependencyValue thatValue = that.getCacheEntryDependencyValue();
106            return _value.equals(thatValue);
107        } else {
108            return false;
109        }
110    }
111    
112    @Override
113    public void store()
114            throws PersistenceDatabaseException {
115        getBaseFactoryInstance().store(this);
116    }
117    
118    @Override
119    public void remove()
120            throws PersistenceDatabaseException {
121        getBaseFactoryInstance().remove(this);
122    }
123    
124    public CacheEntryDependencyValue getCacheEntryDependencyValue() {
125        return _value;
126    }
127    
128    public void setCacheEntryDependencyValue(CacheEntryDependencyValue value)
129            throws PersistenceReadOnlyException {
130        checkReadWrite();
131        _value = value;
132    }
133    
134    @Override
135    public CacheEntryDependencyPK getPrimaryKey() {
136        return _pk;
137    }
138    
139    public CacheEntryPK getCacheEntryPK() {
140        return _value.getCacheEntryPK();
141    }
142    
143    public CacheEntry getCacheEntry(EntityPermission entityPermission) {
144        return CacheEntryFactory.getInstance().getEntityFromPK(entityPermission, getCacheEntryPK());
145    }
146    
147    public CacheEntry getCacheEntry() {
148        return getCacheEntry(EntityPermission.READ_ONLY);
149    }
150    
151    public CacheEntry getCacheEntryForUpdate() {
152        return getCacheEntry(EntityPermission.READ_WRITE);
153    }
154    
155    public void setCacheEntryPK(CacheEntryPK cacheEntryPK)
156            throws PersistenceNotNullException, PersistenceReadOnlyException {
157        checkReadWrite();
158        _value.setCacheEntryPK(cacheEntryPK);
159    }
160    
161    public void setCacheEntry(CacheEntry entity) {
162        setCacheEntryPK(entity == null? null: entity.getPrimaryKey());
163    }
164    
165    public boolean getCacheEntryPKHasBeenModified() {
166        return _value.getCacheEntryPKHasBeenModified();
167    }
168    
169    public EntityInstancePK getEntityInstancePK() {
170        return _value.getEntityInstancePK();
171    }
172    
173    public EntityInstance getEntityInstance(EntityPermission entityPermission) {
174        return EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, getEntityInstancePK());
175    }
176    
177    public EntityInstance getEntityInstance() {
178        return getEntityInstance(EntityPermission.READ_ONLY);
179    }
180    
181    public EntityInstance getEntityInstanceForUpdate() {
182        return getEntityInstance(EntityPermission.READ_WRITE);
183    }
184    
185    public void setEntityInstancePK(EntityInstancePK entityInstancePK)
186            throws PersistenceNotNullException, PersistenceReadOnlyException {
187        checkReadWrite();
188        _value.setEntityInstancePK(entityInstancePK);
189    }
190    
191    public void setEntityInstance(EntityInstance entity) {
192        setEntityInstancePK(entity == null? null: entity.getPrimaryKey());
193    }
194    
195    public boolean getEntityInstancePKHasBeenModified() {
196        return _value.getEntityInstancePKHasBeenModified();
197    }
198    
199}