001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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 * UserSessionValue.java
021 */
022
023package com.echothree.model.data.user.server.value;
024
025import com.echothree.model.data.user.common.pk.UserSessionPK;
026
027import com.echothree.model.data.user.server.factory.UserSessionFactory;
028
029import com.echothree.model.data.user.common.pk.UserVisitPK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.party.common.pk.PartyRelationshipPK;
032
033import com.echothree.util.common.exception.PersistenceCloneException;
034import com.echothree.util.common.exception.PersistenceNotNullException;
035
036import com.echothree.util.server.persistence.BaseValue;
037
038import java.io.Serializable;
039
040public class UserSessionValue
041        extends BaseValue<UserSessionPK>
042        implements Cloneable, Serializable {
043    
044    private UserVisitPK userVisitPK;
045    private boolean userVisitPKHasBeenModified = false;
046    private PartyPK partyPK;
047    private boolean partyPKHasBeenModified = false;
048    private PartyRelationshipPK partyRelationshipPK;
049    private boolean partyRelationshipPKHasBeenModified = false;
050    private Long identityVerifiedTime;
051    private boolean identityVerifiedTimeHasBeenModified = false;
052    private Long fromTime;
053    private boolean fromTimeHasBeenModified = false;
054    private Long thruTime;
055    private boolean thruTimeHasBeenModified = false;
056    
057    private transient Integer _hashCode = null;
058    private transient String _stringValue = null;
059    
060    private void constructFields(UserVisitPK userVisitPK, PartyPK partyPK, PartyRelationshipPK partyRelationshipPK, Long identityVerifiedTime, Long fromTime, Long thruTime)
061            throws PersistenceNotNullException {
062        checkForNull(userVisitPK);
063        this.userVisitPK = userVisitPK;
064        checkForNull(partyPK);
065        this.partyPK = partyPK;
066        this.partyRelationshipPK = partyRelationshipPK;
067        this.identityVerifiedTime = identityVerifiedTime;
068        checkForNull(fromTime);
069        this.fromTime = fromTime;
070        checkForNull(thruTime);
071        this.thruTime = thruTime;
072    }
073    
074    /** Creates a new instance of UserSessionValue */
075    public UserSessionValue(UserSessionPK userSessionPK, UserVisitPK userVisitPK, PartyPK partyPK, PartyRelationshipPK partyRelationshipPK, Long identityVerifiedTime, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super(userSessionPK);
078        constructFields(userVisitPK, partyPK, partyRelationshipPK, identityVerifiedTime, fromTime, thruTime);
079    }
080    
081    /** Creates a new instance of UserSessionValue */
082    public UserSessionValue(UserVisitPK userVisitPK, PartyPK partyPK, PartyRelationshipPK partyRelationshipPK, Long identityVerifiedTime, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super();
085        constructFields(userVisitPK, partyPK, partyRelationshipPK, identityVerifiedTime, fromTime, thruTime);
086    }
087    
088   @Override
089   public UserSessionFactory getBaseFactoryInstance() {
090        return UserSessionFactory.getInstance();
091    }
092    
093    @Override
094    public UserSessionValue clone() {
095        Object result;
096        
097        try {
098            result = super.clone();
099        } catch (CloneNotSupportedException cnse) {
100            // This shouldn't happen, fail when it does.
101            throw new PersistenceCloneException(cnse);
102        }
103        
104        return (UserSessionValue)result;
105    }
106    
107   @Override
108    public UserSessionPK getPrimaryKey() {
109        if(_primaryKey == null) {
110            _primaryKey = new UserSessionPK(entityId);
111        }
112        
113        return _primaryKey;
114    }
115    
116    private void clearHashAndString() {
117        _hashCode = null;
118        _stringValue = null;
119    }
120    
121    @Override
122    public int hashCode() {
123        if(_hashCode == null) {
124            int hashCode = 17;
125            
126            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
127            
128            hashCode = 37 * hashCode + ((userVisitPK != null) ? userVisitPK.hashCode() : 0);
129            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
130            hashCode = 37 * hashCode + ((partyRelationshipPK != null) ? partyRelationshipPK.hashCode() : 0);
131            hashCode = 37 * hashCode + ((identityVerifiedTime != null) ? identityVerifiedTime.hashCode() : 0);
132            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
133            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
134            
135            _hashCode = hashCode;
136        }
137        
138        return _hashCode;
139    }
140    
141    @Override
142    public String toString() {
143        if(_stringValue == null) {
144            _stringValue = "{" + 
145                    "entityId=" + getEntityId() +
146                    ", userVisitPK=" + getUserVisitPK() +
147                    ", partyPK=" + getPartyPK() +
148                    ", partyRelationshipPK=" + getPartyRelationshipPK() +
149                    ", identityVerifiedTime=" + getIdentityVerifiedTime() +
150                    ", fromTime=" + getFromTime() +
151                    ", thruTime=" + getThruTime() +
152                    "}";
153        }
154        return _stringValue;
155    }
156    
157    @Override
158    public boolean equals(Object other) {
159        if(this == other)
160            return true;
161        
162        if(!hasIdentity())
163            return false;
164        
165        if(other instanceof  UserSessionValue that) {
166            if(!that.hasIdentity())
167                return false;
168            
169            Long thisEntityId = getEntityId();
170            Long thatEntityId = that.getEntityId();
171            
172            boolean objectsEqual = thisEntityId.equals(thatEntityId);
173            if(objectsEqual)
174                objectsEqual = isIdentical(that);
175            
176            return objectsEqual;
177        } else {
178            return false;
179        }
180    }
181    
182    public boolean isIdentical(Object other) {
183        if(other instanceof UserSessionValue that) {
184            boolean objectsEqual = true;
185            
186            
187            if(objectsEqual) {
188                UserVisitPK thisUserVisitPK = getUserVisitPK();
189                UserVisitPK thatUserVisitPK = that.getUserVisitPK();
190                
191                if(thisUserVisitPK == null) {
192                    objectsEqual = objectsEqual && (thatUserVisitPK == null);
193                } else {
194                    objectsEqual = objectsEqual && thisUserVisitPK.equals(thatUserVisitPK);
195                }
196            }
197            
198            if(objectsEqual) {
199                PartyPK thisPartyPK = getPartyPK();
200                PartyPK thatPartyPK = that.getPartyPK();
201                
202                if(thisPartyPK == null) {
203                    objectsEqual = objectsEqual && (thatPartyPK == null);
204                } else {
205                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
206                }
207            }
208            
209            if(objectsEqual) {
210                PartyRelationshipPK thisPartyRelationshipPK = getPartyRelationshipPK();
211                PartyRelationshipPK thatPartyRelationshipPK = that.getPartyRelationshipPK();
212                
213                if(thisPartyRelationshipPK == null) {
214                    objectsEqual = objectsEqual && (thatPartyRelationshipPK == null);
215                } else {
216                    objectsEqual = objectsEqual && thisPartyRelationshipPK.equals(thatPartyRelationshipPK);
217                }
218            }
219            
220            if(objectsEqual) {
221                Long thisIdentityVerifiedTime = getIdentityVerifiedTime();
222                Long thatIdentityVerifiedTime = that.getIdentityVerifiedTime();
223                
224                if(thisIdentityVerifiedTime == null) {
225                    objectsEqual = objectsEqual && (thatIdentityVerifiedTime == null);
226                } else {
227                    objectsEqual = objectsEqual && thisIdentityVerifiedTime.equals(thatIdentityVerifiedTime);
228                }
229            }
230            
231            if(objectsEqual) {
232                Long thisFromTime = getFromTime();
233                Long thatFromTime = that.getFromTime();
234                
235                if(thisFromTime == null) {
236                    objectsEqual = objectsEqual && (thatFromTime == null);
237                } else {
238                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
239                }
240            }
241            
242            if(objectsEqual) {
243                Long thisThruTime = getThruTime();
244                Long thatThruTime = that.getThruTime();
245                
246                if(thisThruTime == null) {
247                    objectsEqual = objectsEqual && (thatThruTime == null);
248                } else {
249                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
250                }
251            }
252            
253            return objectsEqual;
254        } else {
255            return false;
256        }
257    }
258    
259    @Override
260    public boolean hasBeenModified() {
261        return userVisitPKHasBeenModified || partyPKHasBeenModified || partyRelationshipPKHasBeenModified || identityVerifiedTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
262    }
263    
264    @Override
265    public void clearHasBeenModified() {
266        userVisitPKHasBeenModified = false;
267        partyPKHasBeenModified = false;
268        partyRelationshipPKHasBeenModified = false;
269        identityVerifiedTimeHasBeenModified = false;
270        fromTimeHasBeenModified = false;
271        thruTimeHasBeenModified = false;
272    }
273    
274    public UserVisitPK getUserVisitPK() {
275        return userVisitPK;
276    }
277    
278    public void setUserVisitPK(UserVisitPK userVisitPK)
279            throws PersistenceNotNullException {
280        checkForNull(userVisitPK);
281        
282        boolean update = true;
283        
284        if(this.userVisitPK != null) {
285            if(this.userVisitPK.equals(userVisitPK)) {
286                update = false;
287            }
288        } else if(userVisitPK == null) {
289            update = false;
290        }
291        
292        if(update) {
293            this.userVisitPK = userVisitPK;
294            userVisitPKHasBeenModified = true;
295            clearHashAndString();
296        }
297    }
298    
299    public boolean getUserVisitPKHasBeenModified() {
300        return userVisitPKHasBeenModified;
301    }
302    
303    public PartyPK getPartyPK() {
304        return partyPK;
305    }
306    
307    public void setPartyPK(PartyPK partyPK)
308            throws PersistenceNotNullException {
309        checkForNull(partyPK);
310        
311        boolean update = true;
312        
313        if(this.partyPK != null) {
314            if(this.partyPK.equals(partyPK)) {
315                update = false;
316            }
317        } else if(partyPK == null) {
318            update = false;
319        }
320        
321        if(update) {
322            this.partyPK = partyPK;
323            partyPKHasBeenModified = true;
324            clearHashAndString();
325        }
326    }
327    
328    public boolean getPartyPKHasBeenModified() {
329        return partyPKHasBeenModified;
330    }
331    
332    public PartyRelationshipPK getPartyRelationshipPK() {
333        return partyRelationshipPK;
334    }
335    
336    public void setPartyRelationshipPK(PartyRelationshipPK partyRelationshipPK) {
337        boolean update = true;
338        
339        if(this.partyRelationshipPK != null) {
340            if(this.partyRelationshipPK.equals(partyRelationshipPK)) {
341                update = false;
342            }
343        } else if(partyRelationshipPK == null) {
344            update = false;
345        }
346        
347        if(update) {
348            this.partyRelationshipPK = partyRelationshipPK;
349            partyRelationshipPKHasBeenModified = true;
350            clearHashAndString();
351        }
352    }
353    
354    public boolean getPartyRelationshipPKHasBeenModified() {
355        return partyRelationshipPKHasBeenModified;
356    }
357    
358    public Long getIdentityVerifiedTime() {
359        return identityVerifiedTime;
360    }
361    
362    public void setIdentityVerifiedTime(Long identityVerifiedTime) {
363        boolean update = true;
364        
365        if(this.identityVerifiedTime != null) {
366            if(this.identityVerifiedTime.equals(identityVerifiedTime)) {
367                update = false;
368            }
369        } else if(identityVerifiedTime == null) {
370            update = false;
371        }
372        
373        if(update) {
374            this.identityVerifiedTime = identityVerifiedTime;
375            identityVerifiedTimeHasBeenModified = true;
376            clearHashAndString();
377        }
378    }
379    
380    public boolean getIdentityVerifiedTimeHasBeenModified() {
381        return identityVerifiedTimeHasBeenModified;
382    }
383    
384    public Long getFromTime() {
385        return fromTime;
386    }
387    
388    public void setFromTime(Long fromTime)
389            throws PersistenceNotNullException {
390        checkForNull(fromTime);
391        
392        boolean update = true;
393        
394        if(this.fromTime != null) {
395            if(this.fromTime.equals(fromTime)) {
396                update = false;
397            }
398        } else if(fromTime == null) {
399            update = false;
400        }
401        
402        if(update) {
403            this.fromTime = fromTime;
404            fromTimeHasBeenModified = true;
405            clearHashAndString();
406        }
407    }
408    
409    public boolean getFromTimeHasBeenModified() {
410        return fromTimeHasBeenModified;
411    }
412    
413    public Long getThruTime() {
414        return thruTime;
415    }
416    
417    public void setThruTime(Long thruTime)
418            throws PersistenceNotNullException {
419        checkForNull(thruTime);
420        
421        boolean update = true;
422        
423        if(this.thruTime != null) {
424            if(this.thruTime.equals(thruTime)) {
425                update = false;
426            }
427        } else if(thruTime == null) {
428            update = false;
429        }
430        
431        if(update) {
432            this.thruTime = thruTime;
433            thruTimeHasBeenModified = true;
434            clearHashAndString();
435        }
436    }
437    
438    public boolean getThruTimeHasBeenModified() {
439        return thruTimeHasBeenModified;
440    }
441    
442}