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 * UserSession.java
021 */
022
023package com.echothree.model.data.user.server.entity;
024
025import com.echothree.model.data.user.common.pk.UserSessionPK;
026
027import com.echothree.model.data.user.common.pk.UserVisitPK;
028import com.echothree.model.data.party.common.pk.PartyPK;
029import com.echothree.model.data.party.common.pk.PartyRelationshipPK;
030
031import com.echothree.model.data.user.server.entity.UserVisit;
032import com.echothree.model.data.party.server.entity.Party;
033import com.echothree.model.data.party.server.entity.PartyRelationship;
034
035import com.echothree.model.data.user.server.factory.UserVisitFactory;
036import com.echothree.model.data.party.server.factory.PartyFactory;
037import com.echothree.model.data.party.server.factory.PartyRelationshipFactory;
038
039import com.echothree.model.data.user.common.pk.UserSessionPK;
040
041import com.echothree.model.data.user.server.value.UserSessionValue;
042
043import com.echothree.model.data.user.server.factory.UserSessionFactory;
044
045import com.echothree.util.common.exception.PersistenceException;
046import com.echothree.util.common.exception.PersistenceDatabaseException;
047import com.echothree.util.common.exception.PersistenceNotNullException;
048import com.echothree.util.common.exception.PersistenceReadOnlyException;
049
050import com.echothree.util.common.persistence.BasePK;
051
052import com.echothree.util.common.persistence.type.ByteArray;
053
054import com.echothree.util.server.persistence.BaseEntity;
055import com.echothree.util.server.persistence.EntityPermission;
056import com.echothree.util.server.persistence.Session;
057import com.echothree.util.server.persistence.ThreadSession;
058
059import java.io.Serializable;
060
061import javax.annotation.Nonnull;
062import javax.annotation.Nullable;
063
064public class UserSession
065        extends BaseEntity
066        implements Serializable {
067    
068    private UserSessionPK _pk;
069    private UserSessionValue _value;
070    
071    /** Creates a new instance of UserSession */
072    public UserSession()
073            throws PersistenceException {
074        super();
075    }
076    
077    /** Creates a new instance of UserSession */
078    public UserSession(UserSessionValue value, EntityPermission entityPermission) {
079        super(entityPermission);
080        
081        _value = value;
082        _pk = value.getPrimaryKey();
083    }
084    
085    @Override
086    @Nonnull
087    public UserSessionFactory getBaseFactoryInstance() {
088        return UserSessionFactory.getInstance();
089    }
090    
091    @Override
092    public boolean hasBeenModified() {
093        return _value.hasBeenModified();
094    }
095    
096    @Override
097    public int hashCode() {
098        return _pk.hashCode();
099    }
100    
101    @Override
102    @Nonnull
103    public String toString() {
104        return _pk.toString();
105    }
106    
107    @Override
108    public boolean equals(Object other) {
109        if(this == other)
110            return true;
111        
112        if(other instanceof UserSession that) {
113            UserSessionValue thatValue = that.getUserSessionValue();
114            return _value.equals(thatValue);
115        } else {
116            return false;
117        }
118    }
119    
120    @Override
121    public void store()
122            throws PersistenceDatabaseException {
123        getBaseFactoryInstance().store(this);
124    }
125    
126    @Override
127    public void remove()
128            throws PersistenceDatabaseException {
129        getBaseFactoryInstance().remove(this);
130    }
131    
132    @Nonnull
133    public UserSessionValue getUserSessionValue() {
134        return _value;
135    }
136    
137    public void setUserSessionValue(@Nonnull UserSessionValue value)
138            throws PersistenceReadOnlyException {
139        checkReadWrite();
140        _value = value;
141    }
142    
143    @Override
144    @Nonnull
145    public UserSessionPK getPrimaryKey() {
146        return _pk;
147    }
148    
149    @Nonnull
150    public UserVisitPK getUserVisitPK() {
151        return _value.getUserVisitPK();
152    }
153    
154    @Nonnull
155    public UserVisit getUserVisit(EntityPermission entityPermission) {
156        return UserVisitFactory.getInstance().getEntityFromPK(entityPermission, getUserVisitPK());
157    }
158    
159    @Nonnull
160    public UserVisit getUserVisit() {
161        return getUserVisit(EntityPermission.READ_ONLY);
162    }
163    
164    @Nonnull
165    public UserVisit getUserVisitForUpdate() {
166        return getUserVisit(EntityPermission.READ_WRITE);
167    }
168    
169    public void setUserVisitPK(@Nonnull UserVisitPK userVisitPK)
170            throws PersistenceNotNullException, PersistenceReadOnlyException {
171        checkReadWrite();
172        _value.setUserVisitPK(userVisitPK);
173    }
174    
175    public void setUserVisit(@Nonnull UserVisit entity) {
176        setUserVisitPK(entity == null ? null : entity.getPrimaryKey());
177    }
178    
179    public boolean getUserVisitPKHasBeenModified() {
180        return _value.getUserVisitPKHasBeenModified();
181    }
182    
183    @Nonnull
184    public PartyPK getPartyPK() {
185        return _value.getPartyPK();
186    }
187    
188    @Nonnull
189    public Party getParty(EntityPermission entityPermission) {
190        return PartyFactory.getInstance().getEntityFromPK(entityPermission, getPartyPK());
191    }
192    
193    @Nonnull
194    public Party getParty() {
195        return getParty(EntityPermission.READ_ONLY);
196    }
197    
198    @Nonnull
199    public Party getPartyForUpdate() {
200        return getParty(EntityPermission.READ_WRITE);
201    }
202    
203    public void setPartyPK(@Nonnull PartyPK partyPK)
204            throws PersistenceNotNullException, PersistenceReadOnlyException {
205        checkReadWrite();
206        _value.setPartyPK(partyPK);
207    }
208    
209    public void setParty(@Nonnull Party entity) {
210        setPartyPK(entity == null ? null : entity.getPrimaryKey());
211    }
212    
213    public boolean getPartyPKHasBeenModified() {
214        return _value.getPartyPKHasBeenModified();
215    }
216    
217    @Nullable
218    public PartyRelationshipPK getPartyRelationshipPK() {
219        return _value.getPartyRelationshipPK();
220    }
221    
222    @Nullable
223    public PartyRelationship getPartyRelationship(EntityPermission entityPermission) {
224        PartyRelationshipPK pk = getPartyRelationshipPK();
225        PartyRelationship entity = pk == null? null: PartyRelationshipFactory.getInstance().getEntityFromPK(entityPermission, pk);
226        
227        return entity;
228    }
229    
230    @Nullable
231    public PartyRelationship getPartyRelationship() {
232        return getPartyRelationship(EntityPermission.READ_ONLY);
233    }
234    
235    @Nullable
236    public PartyRelationship getPartyRelationshipForUpdate() {
237        return getPartyRelationship(EntityPermission.READ_WRITE);
238    }
239    
240    public void setPartyRelationshipPK(@Nullable PartyRelationshipPK partyRelationshipPK)
241            throws PersistenceNotNullException, PersistenceReadOnlyException {
242        checkReadWrite();
243        _value.setPartyRelationshipPK(partyRelationshipPK);
244    }
245    
246    public void setPartyRelationship(@Nullable PartyRelationship entity) {
247        setPartyRelationshipPK(entity == null ? null : entity.getPrimaryKey());
248    }
249    
250    public boolean getPartyRelationshipPKHasBeenModified() {
251        return _value.getPartyRelationshipPKHasBeenModified();
252    }
253    
254    @Nullable
255    public Long getIdentityVerifiedTime() {
256        return _value.getIdentityVerifiedTime();
257    }
258    
259    public void setIdentityVerifiedTime(@Nullable Long identityVerifiedTime)
260            throws PersistenceNotNullException, PersistenceReadOnlyException {
261        checkReadWrite();
262        _value.setIdentityVerifiedTime(identityVerifiedTime);
263    }
264    
265    public boolean getIdentityVerifiedTimeHasBeenModified() {
266        return _value.getIdentityVerifiedTimeHasBeenModified();
267    }
268    
269    @Nonnull
270    public Long getFromTime() {
271        return _value.getFromTime();
272    }
273    
274    public void setFromTime(@Nonnull Long fromTime)
275            throws PersistenceNotNullException, PersistenceReadOnlyException {
276        checkReadWrite();
277        _value.setFromTime(fromTime);
278    }
279    
280    public boolean getFromTimeHasBeenModified() {
281        return _value.getFromTimeHasBeenModified();
282    }
283    
284    @Nonnull
285    public Long getThruTime() {
286        return _value.getThruTime();
287    }
288    
289    public void setThruTime(@Nonnull Long thruTime)
290            throws PersistenceNotNullException, PersistenceReadOnlyException {
291        checkReadWrite();
292        _value.setThruTime(thruTime);
293    }
294    
295    public boolean getThruTimeHasBeenModified() {
296        return _value.getThruTimeHasBeenModified();
297    }
298    
299}