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 * CachedExecutedSearchValue.java
021 */
022
023package com.echothree.model.data.search.server.value;
024
025import com.echothree.model.data.search.common.pk.CachedExecutedSearchPK;
026
027import com.echothree.model.data.search.server.factory.CachedExecutedSearchFactory;
028
029import com.echothree.model.data.search.common.pk.CachedSearchPK;
030
031import com.echothree.util.common.exception.PersistenceCloneException;
032import com.echothree.util.common.exception.PersistenceNotNullException;
033
034import com.echothree.util.server.persistence.BaseValue;
035
036import java.io.Serializable;
037
038import javax.annotation.Nonnull;
039import javax.annotation.Nullable;
040
041public class CachedExecutedSearchValue
042        extends BaseValue<CachedExecutedSearchPK>
043        implements Cloneable, Serializable {
044    
045    private CachedSearchPK cachedSearchPK;
046    private boolean cachedSearchPKHasBeenModified = false;
047    private Long fromTime;
048    private boolean fromTimeHasBeenModified = false;
049    private Long thruTime;
050    private boolean thruTimeHasBeenModified = false;
051    
052    private transient Integer _hashCode = null;
053    private transient String _stringValue = null;
054    
055    private void constructFields(CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
056            throws PersistenceNotNullException {
057        checkForNull(cachedSearchPK);
058        this.cachedSearchPK = cachedSearchPK;
059        checkForNull(fromTime);
060        this.fromTime = fromTime;
061        checkForNull(thruTime);
062        this.thruTime = thruTime;
063    }
064    
065    /** Creates a new instance of CachedExecutedSearchValue */
066    public CachedExecutedSearchValue(CachedExecutedSearchPK cachedExecutedSearchPK, CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
067            throws PersistenceNotNullException {
068        super(cachedExecutedSearchPK);
069        constructFields(cachedSearchPK, fromTime, thruTime);
070    }
071    
072    /** Creates a new instance of CachedExecutedSearchValue */
073    public CachedExecutedSearchValue(CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
074            throws PersistenceNotNullException {
075        super();
076        constructFields(cachedSearchPK, fromTime, thruTime);
077    }
078    
079    @Override
080    @Nonnull
081    public CachedExecutedSearchFactory getBaseFactoryInstance() {
082        return CachedExecutedSearchFactory.getInstance();
083    }
084    
085    @Override
086    @Nonnull
087    public CachedExecutedSearchValue clone() {
088        Object result;
089        
090        try {
091            result = super.clone();
092        } catch (CloneNotSupportedException cnse) {
093            // This shouldn't happen, fail when it does.
094            throw new PersistenceCloneException(cnse);
095        }
096        
097        return (CachedExecutedSearchValue)result;
098    }
099    
100    @Override
101    @Nonnull
102    public CachedExecutedSearchPK getPrimaryKey() {
103        if(_primaryKey == null) {
104            _primaryKey = new CachedExecutedSearchPK(entityId);
105        }
106        
107        return _primaryKey;
108    }
109    
110    private void clearHashAndString() {
111        _hashCode = null;
112        _stringValue = null;
113    }
114    
115    @Override
116    public int hashCode() {
117        if(_hashCode == null) {
118            int hashCode = 17;
119            
120            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
121            
122            hashCode = 37 * hashCode + ((cachedSearchPK != null) ? cachedSearchPK.hashCode() : 0);
123            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
124            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
125            
126            _hashCode = hashCode;
127        }
128        
129        return _hashCode;
130    }
131    
132    @Override
133    @Nonnull
134    public String toString() {
135        if(_stringValue == null) {
136            _stringValue = "{" + 
137                    "entityId=" + getEntityId() +
138                    ", cachedSearchPK=" + getCachedSearchPK() +
139                    ", fromTime=" + getFromTime() +
140                    ", thruTime=" + getThruTime() +
141                    "}";
142        }
143        return _stringValue;
144    }
145    
146    @Override
147    public boolean equals(Object other) {
148        if(this == other)
149            return true;
150        
151        if(!hasIdentity())
152            return false;
153        
154        if(other instanceof  CachedExecutedSearchValue that) {
155            if(!that.hasIdentity())
156                return false;
157            
158            Long thisEntityId = getEntityId();
159            Long thatEntityId = that.getEntityId();
160            
161            boolean objectsEqual = thisEntityId.equals(thatEntityId);
162            if(objectsEqual)
163                objectsEqual = isIdentical(that);
164            
165            return objectsEqual;
166        } else {
167            return false;
168        }
169    }
170    
171    public boolean isIdentical(Object other) {
172        if(other instanceof CachedExecutedSearchValue that) {
173            boolean objectsEqual = true;
174            
175            
176            if(objectsEqual) {
177                CachedSearchPK thisCachedSearchPK = getCachedSearchPK();
178                CachedSearchPK thatCachedSearchPK = that.getCachedSearchPK();
179                
180                if(thisCachedSearchPK == null) {
181                    objectsEqual = objectsEqual && (thatCachedSearchPK == null);
182                } else {
183                    objectsEqual = objectsEqual && thisCachedSearchPK.equals(thatCachedSearchPK);
184                }
185            }
186            
187            if(objectsEqual) {
188                Long thisFromTime = getFromTime();
189                Long thatFromTime = that.getFromTime();
190                
191                if(thisFromTime == null) {
192                    objectsEqual = objectsEqual && (thatFromTime == null);
193                } else {
194                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
195                }
196            }
197            
198            if(objectsEqual) {
199                Long thisThruTime = getThruTime();
200                Long thatThruTime = that.getThruTime();
201                
202                if(thisThruTime == null) {
203                    objectsEqual = objectsEqual && (thatThruTime == null);
204                } else {
205                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
206                }
207            }
208            
209            return objectsEqual;
210        } else {
211            return false;
212        }
213    }
214    
215    @Override
216    public boolean hasBeenModified() {
217        return cachedSearchPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
218    }
219    
220    @Override
221    public void clearHasBeenModified() {
222        cachedSearchPKHasBeenModified = false;
223        fromTimeHasBeenModified = false;
224        thruTimeHasBeenModified = false;
225    }
226    
227    @Nonnull
228    public CachedSearchPK getCachedSearchPK() {
229        return cachedSearchPK;
230    }
231    
232    public void setCachedSearchPK(@Nonnull CachedSearchPK cachedSearchPK)
233            throws PersistenceNotNullException {
234        checkForNull(cachedSearchPK);
235        
236        boolean update = true;
237        
238        if(this.cachedSearchPK != null) {
239            if(this.cachedSearchPK.equals(cachedSearchPK)) {
240                update = false;
241            }
242        } else if(cachedSearchPK == null) {
243            update = false;
244        }
245        
246        if(update) {
247            this.cachedSearchPK = cachedSearchPK;
248            cachedSearchPKHasBeenModified = true;
249            clearHashAndString();
250        }
251    }
252    
253    public boolean getCachedSearchPKHasBeenModified() {
254        return cachedSearchPKHasBeenModified;
255    }
256    
257    @Nonnull
258    public Long getFromTime() {
259        return fromTime;
260    }
261    
262    public void setFromTime(@Nonnull Long fromTime)
263            throws PersistenceNotNullException {
264        checkForNull(fromTime);
265        
266        boolean update = true;
267        
268        if(this.fromTime != null) {
269            if(this.fromTime.equals(fromTime)) {
270                update = false;
271            }
272        } else if(fromTime == null) {
273            update = false;
274        }
275        
276        if(update) {
277            this.fromTime = fromTime;
278            fromTimeHasBeenModified = true;
279            clearHashAndString();
280        }
281    }
282    
283    public boolean getFromTimeHasBeenModified() {
284        return fromTimeHasBeenModified;
285    }
286    
287    @Nonnull
288    public Long getThruTime() {
289        return thruTime;
290    }
291    
292    public void setThruTime(@Nonnull Long thruTime)
293            throws PersistenceNotNullException {
294        checkForNull(thruTime);
295        
296        boolean update = true;
297        
298        if(this.thruTime != null) {
299            if(this.thruTime.equals(thruTime)) {
300                update = false;
301            }
302        } else if(thruTime == null) {
303            update = false;
304        }
305        
306        if(update) {
307            this.thruTime = thruTime;
308            thruTimeHasBeenModified = true;
309            clearHashAndString();
310        }
311    }
312    
313    public boolean getThruTimeHasBeenModified() {
314        return thruTimeHasBeenModified;
315    }
316    
317}