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 * CachedSearchValue.java
021 */
022
023package com.echothree.model.data.search.server.value;
024
025import com.echothree.model.data.search.common.pk.CachedSearchPK;
026
027import com.echothree.model.data.search.server.factory.CachedSearchFactory;
028
029import com.echothree.model.data.index.common.pk.IndexPK;
030import com.echothree.model.data.search.common.pk.SearchDefaultOperatorPK;
031import com.echothree.model.data.search.common.pk.SearchSortOrderPK;
032import com.echothree.model.data.search.common.pk.SearchSortDirectionPK;
033
034import com.echothree.util.common.exception.PersistenceCloneException;
035import com.echothree.util.common.exception.PersistenceNotNullException;
036
037import com.echothree.util.server.persistence.BaseValue;
038
039import java.io.Serializable;
040
041import javax.annotation.Nonnull;
042import javax.annotation.Nullable;
043
044public class CachedSearchValue
045        extends BaseValue<CachedSearchPK>
046        implements Cloneable, Serializable {
047    
048    private IndexPK indexPK;
049    private boolean indexPKHasBeenModified = false;
050    private String querySha1Hash;
051    private boolean querySha1HashHasBeenModified = false;
052    private String query;
053    private boolean queryHasBeenModified = false;
054    private String parsedQuerySha1Hash;
055    private boolean parsedQuerySha1HashHasBeenModified = false;
056    private String parsedQuery;
057    private boolean parsedQueryHasBeenModified = false;
058    private SearchDefaultOperatorPK searchDefaultOperatorPK;
059    private boolean searchDefaultOperatorPKHasBeenModified = false;
060    private SearchSortOrderPK searchSortOrderPK;
061    private boolean searchSortOrderPKHasBeenModified = false;
062    private SearchSortDirectionPK searchSortDirectionPK;
063    private boolean searchSortDirectionPKHasBeenModified = false;
064    private Long fromTime;
065    private boolean fromTimeHasBeenModified = false;
066    private Long thruTime;
067    private boolean thruTimeHasBeenModified = false;
068    
069    private transient Integer _hashCode = null;
070    private transient String _stringValue = null;
071    
072    private void constructFields(IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime)
073            throws PersistenceNotNullException {
074        checkForNull(indexPK);
075        this.indexPK = indexPK;
076        checkForNull(querySha1Hash);
077        this.querySha1Hash = querySha1Hash;
078        checkForNull(query);
079        this.query = query;
080        checkForNull(parsedQuerySha1Hash);
081        this.parsedQuerySha1Hash = parsedQuerySha1Hash;
082        checkForNull(parsedQuery);
083        this.parsedQuery = parsedQuery;
084        checkForNull(searchDefaultOperatorPK);
085        this.searchDefaultOperatorPK = searchDefaultOperatorPK;
086        checkForNull(searchSortOrderPK);
087        this.searchSortOrderPK = searchSortOrderPK;
088        checkForNull(searchSortDirectionPK);
089        this.searchSortDirectionPK = searchSortDirectionPK;
090        checkForNull(fromTime);
091        this.fromTime = fromTime;
092        checkForNull(thruTime);
093        this.thruTime = thruTime;
094    }
095    
096    /** Creates a new instance of CachedSearchValue */
097    public CachedSearchValue(CachedSearchPK cachedSearchPK, IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime)
098            throws PersistenceNotNullException {
099        super(cachedSearchPK);
100        constructFields(indexPK, querySha1Hash, query, parsedQuerySha1Hash, parsedQuery, searchDefaultOperatorPK, searchSortOrderPK, searchSortDirectionPK, fromTime, thruTime);
101    }
102    
103    /** Creates a new instance of CachedSearchValue */
104    public CachedSearchValue(IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime)
105            throws PersistenceNotNullException {
106        super();
107        constructFields(indexPK, querySha1Hash, query, parsedQuerySha1Hash, parsedQuery, searchDefaultOperatorPK, searchSortOrderPK, searchSortDirectionPK, fromTime, thruTime);
108    }
109    
110    @Override
111    @Nonnull
112    public CachedSearchFactory getBaseFactoryInstance() {
113        return CachedSearchFactory.getInstance();
114    }
115    
116    @Override
117    @Nonnull
118    public CachedSearchValue clone() {
119        Object result;
120        
121        try {
122            result = super.clone();
123        } catch (CloneNotSupportedException cnse) {
124            // This shouldn't happen, fail when it does.
125            throw new PersistenceCloneException(cnse);
126        }
127        
128        return (CachedSearchValue)result;
129    }
130    
131    @Override
132    @Nonnull
133    public CachedSearchPK getPrimaryKey() {
134        if(_primaryKey == null) {
135            _primaryKey = new CachedSearchPK(entityId);
136        }
137        
138        return _primaryKey;
139    }
140    
141    private void clearHashAndString() {
142        _hashCode = null;
143        _stringValue = null;
144    }
145    
146    @Override
147    public int hashCode() {
148        if(_hashCode == null) {
149            int hashCode = 17;
150            
151            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
152            
153            hashCode = 37 * hashCode + ((indexPK != null) ? indexPK.hashCode() : 0);
154            hashCode = 37 * hashCode + ((querySha1Hash != null) ? querySha1Hash.hashCode() : 0);
155            hashCode = 37 * hashCode + ((query != null) ? query.hashCode() : 0);
156            hashCode = 37 * hashCode + ((parsedQuerySha1Hash != null) ? parsedQuerySha1Hash.hashCode() : 0);
157            hashCode = 37 * hashCode + ((parsedQuery != null) ? parsedQuery.hashCode() : 0);
158            hashCode = 37 * hashCode + ((searchDefaultOperatorPK != null) ? searchDefaultOperatorPK.hashCode() : 0);
159            hashCode = 37 * hashCode + ((searchSortOrderPK != null) ? searchSortOrderPK.hashCode() : 0);
160            hashCode = 37 * hashCode + ((searchSortDirectionPK != null) ? searchSortDirectionPK.hashCode() : 0);
161            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
162            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
163            
164            _hashCode = hashCode;
165        }
166        
167        return _hashCode;
168    }
169    
170    @Override
171    @Nonnull
172    public String toString() {
173        if(_stringValue == null) {
174            _stringValue = "{" + 
175                    "entityId=" + getEntityId() +
176                    ", indexPK=" + getIndexPK() +
177                    ", querySha1Hash=" + getQuerySha1Hash() +
178                    ", query=" + getQuery() +
179                    ", parsedQuerySha1Hash=" + getParsedQuerySha1Hash() +
180                    ", parsedQuery=" + getParsedQuery() +
181                    ", searchDefaultOperatorPK=" + getSearchDefaultOperatorPK() +
182                    ", searchSortOrderPK=" + getSearchSortOrderPK() +
183                    ", searchSortDirectionPK=" + getSearchSortDirectionPK() +
184                    ", fromTime=" + getFromTime() +
185                    ", thruTime=" + getThruTime() +
186                    "}";
187        }
188        return _stringValue;
189    }
190    
191    @Override
192    public boolean equals(Object other) {
193        if(this == other)
194            return true;
195        
196        if(!hasIdentity())
197            return false;
198        
199        if(other instanceof  CachedSearchValue that) {
200            if(!that.hasIdentity())
201                return false;
202            
203            Long thisEntityId = getEntityId();
204            Long thatEntityId = that.getEntityId();
205            
206            boolean objectsEqual = thisEntityId.equals(thatEntityId);
207            if(objectsEqual)
208                objectsEqual = isIdentical(that);
209            
210            return objectsEqual;
211        } else {
212            return false;
213        }
214    }
215    
216    public boolean isIdentical(Object other) {
217        if(other instanceof CachedSearchValue that) {
218            boolean objectsEqual = true;
219            
220            
221            if(objectsEqual) {
222                IndexPK thisIndexPK = getIndexPK();
223                IndexPK thatIndexPK = that.getIndexPK();
224                
225                if(thisIndexPK == null) {
226                    objectsEqual = objectsEqual && (thatIndexPK == null);
227                } else {
228                    objectsEqual = objectsEqual && thisIndexPK.equals(thatIndexPK);
229                }
230            }
231            
232            if(objectsEqual) {
233                String thisQuerySha1Hash = getQuerySha1Hash();
234                String thatQuerySha1Hash = that.getQuerySha1Hash();
235                
236                if(thisQuerySha1Hash == null) {
237                    objectsEqual = objectsEqual && (thatQuerySha1Hash == null);
238                } else {
239                    objectsEqual = objectsEqual && thisQuerySha1Hash.equals(thatQuerySha1Hash);
240                }
241            }
242            
243            if(objectsEqual) {
244                String thisQuery = getQuery();
245                String thatQuery = that.getQuery();
246                
247                if(thisQuery == null) {
248                    objectsEqual = objectsEqual && (thatQuery == null);
249                } else {
250                    objectsEqual = objectsEqual && thisQuery.equals(thatQuery);
251                }
252            }
253            
254            if(objectsEqual) {
255                String thisParsedQuerySha1Hash = getParsedQuerySha1Hash();
256                String thatParsedQuerySha1Hash = that.getParsedQuerySha1Hash();
257                
258                if(thisParsedQuerySha1Hash == null) {
259                    objectsEqual = objectsEqual && (thatParsedQuerySha1Hash == null);
260                } else {
261                    objectsEqual = objectsEqual && thisParsedQuerySha1Hash.equals(thatParsedQuerySha1Hash);
262                }
263            }
264            
265            if(objectsEqual) {
266                String thisParsedQuery = getParsedQuery();
267                String thatParsedQuery = that.getParsedQuery();
268                
269                if(thisParsedQuery == null) {
270                    objectsEqual = objectsEqual && (thatParsedQuery == null);
271                } else {
272                    objectsEqual = objectsEqual && thisParsedQuery.equals(thatParsedQuery);
273                }
274            }
275            
276            if(objectsEqual) {
277                SearchDefaultOperatorPK thisSearchDefaultOperatorPK = getSearchDefaultOperatorPK();
278                SearchDefaultOperatorPK thatSearchDefaultOperatorPK = that.getSearchDefaultOperatorPK();
279                
280                if(thisSearchDefaultOperatorPK == null) {
281                    objectsEqual = objectsEqual && (thatSearchDefaultOperatorPK == null);
282                } else {
283                    objectsEqual = objectsEqual && thisSearchDefaultOperatorPK.equals(thatSearchDefaultOperatorPK);
284                }
285            }
286            
287            if(objectsEqual) {
288                SearchSortOrderPK thisSearchSortOrderPK = getSearchSortOrderPK();
289                SearchSortOrderPK thatSearchSortOrderPK = that.getSearchSortOrderPK();
290                
291                if(thisSearchSortOrderPK == null) {
292                    objectsEqual = objectsEqual && (thatSearchSortOrderPK == null);
293                } else {
294                    objectsEqual = objectsEqual && thisSearchSortOrderPK.equals(thatSearchSortOrderPK);
295                }
296            }
297            
298            if(objectsEqual) {
299                SearchSortDirectionPK thisSearchSortDirectionPK = getSearchSortDirectionPK();
300                SearchSortDirectionPK thatSearchSortDirectionPK = that.getSearchSortDirectionPK();
301                
302                if(thisSearchSortDirectionPK == null) {
303                    objectsEqual = objectsEqual && (thatSearchSortDirectionPK == null);
304                } else {
305                    objectsEqual = objectsEqual && thisSearchSortDirectionPK.equals(thatSearchSortDirectionPK);
306                }
307            }
308            
309            if(objectsEqual) {
310                Long thisFromTime = getFromTime();
311                Long thatFromTime = that.getFromTime();
312                
313                if(thisFromTime == null) {
314                    objectsEqual = objectsEqual && (thatFromTime == null);
315                } else {
316                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
317                }
318            }
319            
320            if(objectsEqual) {
321                Long thisThruTime = getThruTime();
322                Long thatThruTime = that.getThruTime();
323                
324                if(thisThruTime == null) {
325                    objectsEqual = objectsEqual && (thatThruTime == null);
326                } else {
327                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
328                }
329            }
330            
331            return objectsEqual;
332        } else {
333            return false;
334        }
335    }
336    
337    @Override
338    public boolean hasBeenModified() {
339        return indexPKHasBeenModified || querySha1HashHasBeenModified || queryHasBeenModified || parsedQuerySha1HashHasBeenModified || parsedQueryHasBeenModified || searchDefaultOperatorPKHasBeenModified || searchSortOrderPKHasBeenModified || searchSortDirectionPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
340    }
341    
342    @Override
343    public void clearHasBeenModified() {
344        indexPKHasBeenModified = false;
345        querySha1HashHasBeenModified = false;
346        queryHasBeenModified = false;
347        parsedQuerySha1HashHasBeenModified = false;
348        parsedQueryHasBeenModified = false;
349        searchDefaultOperatorPKHasBeenModified = false;
350        searchSortOrderPKHasBeenModified = false;
351        searchSortDirectionPKHasBeenModified = false;
352        fromTimeHasBeenModified = false;
353        thruTimeHasBeenModified = false;
354    }
355    
356    @Nonnull
357    public IndexPK getIndexPK() {
358        return indexPK;
359    }
360    
361    public void setIndexPK(@Nonnull IndexPK indexPK)
362            throws PersistenceNotNullException {
363        checkForNull(indexPK);
364        
365        boolean update = true;
366        
367        if(this.indexPK != null) {
368            if(this.indexPK.equals(indexPK)) {
369                update = false;
370            }
371        } else if(indexPK == null) {
372            update = false;
373        }
374        
375        if(update) {
376            this.indexPK = indexPK;
377            indexPKHasBeenModified = true;
378            clearHashAndString();
379        }
380    }
381    
382    public boolean getIndexPKHasBeenModified() {
383        return indexPKHasBeenModified;
384    }
385    
386    @Nonnull
387    public String getQuerySha1Hash() {
388        return querySha1Hash;
389    }
390    
391    public void setQuerySha1Hash(@Nonnull String querySha1Hash)
392            throws PersistenceNotNullException {
393        checkForNull(querySha1Hash);
394        
395        boolean update = true;
396        
397        if(this.querySha1Hash != null) {
398            if(this.querySha1Hash.equals(querySha1Hash)) {
399                update = false;
400            }
401        } else if(querySha1Hash == null) {
402            update = false;
403        }
404        
405        if(update) {
406            this.querySha1Hash = querySha1Hash;
407            querySha1HashHasBeenModified = true;
408            clearHashAndString();
409        }
410    }
411    
412    public boolean getQuerySha1HashHasBeenModified() {
413        return querySha1HashHasBeenModified;
414    }
415    
416    @Nonnull
417    public String getQuery() {
418        return query;
419    }
420    
421    public void setQuery(@Nonnull String query)
422            throws PersistenceNotNullException {
423        checkForNull(query);
424        
425        boolean update = true;
426        
427        if(this.query != null) {
428            if(this.query.equals(query)) {
429                update = false;
430            }
431        } else if(query == null) {
432            update = false;
433        }
434        
435        if(update) {
436            this.query = query;
437            queryHasBeenModified = true;
438            clearHashAndString();
439        }
440    }
441    
442    public boolean getQueryHasBeenModified() {
443        return queryHasBeenModified;
444    }
445    
446    @Nonnull
447    public String getParsedQuerySha1Hash() {
448        return parsedQuerySha1Hash;
449    }
450    
451    public void setParsedQuerySha1Hash(@Nonnull String parsedQuerySha1Hash)
452            throws PersistenceNotNullException {
453        checkForNull(parsedQuerySha1Hash);
454        
455        boolean update = true;
456        
457        if(this.parsedQuerySha1Hash != null) {
458            if(this.parsedQuerySha1Hash.equals(parsedQuerySha1Hash)) {
459                update = false;
460            }
461        } else if(parsedQuerySha1Hash == null) {
462            update = false;
463        }
464        
465        if(update) {
466            this.parsedQuerySha1Hash = parsedQuerySha1Hash;
467            parsedQuerySha1HashHasBeenModified = true;
468            clearHashAndString();
469        }
470    }
471    
472    public boolean getParsedQuerySha1HashHasBeenModified() {
473        return parsedQuerySha1HashHasBeenModified;
474    }
475    
476    @Nonnull
477    public String getParsedQuery() {
478        return parsedQuery;
479    }
480    
481    public void setParsedQuery(@Nonnull String parsedQuery)
482            throws PersistenceNotNullException {
483        checkForNull(parsedQuery);
484        
485        boolean update = true;
486        
487        if(this.parsedQuery != null) {
488            if(this.parsedQuery.equals(parsedQuery)) {
489                update = false;
490            }
491        } else if(parsedQuery == null) {
492            update = false;
493        }
494        
495        if(update) {
496            this.parsedQuery = parsedQuery;
497            parsedQueryHasBeenModified = true;
498            clearHashAndString();
499        }
500    }
501    
502    public boolean getParsedQueryHasBeenModified() {
503        return parsedQueryHasBeenModified;
504    }
505    
506    @Nonnull
507    public SearchDefaultOperatorPK getSearchDefaultOperatorPK() {
508        return searchDefaultOperatorPK;
509    }
510    
511    public void setSearchDefaultOperatorPK(@Nonnull SearchDefaultOperatorPK searchDefaultOperatorPK)
512            throws PersistenceNotNullException {
513        checkForNull(searchDefaultOperatorPK);
514        
515        boolean update = true;
516        
517        if(this.searchDefaultOperatorPK != null) {
518            if(this.searchDefaultOperatorPK.equals(searchDefaultOperatorPK)) {
519                update = false;
520            }
521        } else if(searchDefaultOperatorPK == null) {
522            update = false;
523        }
524        
525        if(update) {
526            this.searchDefaultOperatorPK = searchDefaultOperatorPK;
527            searchDefaultOperatorPKHasBeenModified = true;
528            clearHashAndString();
529        }
530    }
531    
532    public boolean getSearchDefaultOperatorPKHasBeenModified() {
533        return searchDefaultOperatorPKHasBeenModified;
534    }
535    
536    @Nonnull
537    public SearchSortOrderPK getSearchSortOrderPK() {
538        return searchSortOrderPK;
539    }
540    
541    public void setSearchSortOrderPK(@Nonnull SearchSortOrderPK searchSortOrderPK)
542            throws PersistenceNotNullException {
543        checkForNull(searchSortOrderPK);
544        
545        boolean update = true;
546        
547        if(this.searchSortOrderPK != null) {
548            if(this.searchSortOrderPK.equals(searchSortOrderPK)) {
549                update = false;
550            }
551        } else if(searchSortOrderPK == null) {
552            update = false;
553        }
554        
555        if(update) {
556            this.searchSortOrderPK = searchSortOrderPK;
557            searchSortOrderPKHasBeenModified = true;
558            clearHashAndString();
559        }
560    }
561    
562    public boolean getSearchSortOrderPKHasBeenModified() {
563        return searchSortOrderPKHasBeenModified;
564    }
565    
566    @Nonnull
567    public SearchSortDirectionPK getSearchSortDirectionPK() {
568        return searchSortDirectionPK;
569    }
570    
571    public void setSearchSortDirectionPK(@Nonnull SearchSortDirectionPK searchSortDirectionPK)
572            throws PersistenceNotNullException {
573        checkForNull(searchSortDirectionPK);
574        
575        boolean update = true;
576        
577        if(this.searchSortDirectionPK != null) {
578            if(this.searchSortDirectionPK.equals(searchSortDirectionPK)) {
579                update = false;
580            }
581        } else if(searchSortDirectionPK == null) {
582            update = false;
583        }
584        
585        if(update) {
586            this.searchSortDirectionPK = searchSortDirectionPK;
587            searchSortDirectionPKHasBeenModified = true;
588            clearHashAndString();
589        }
590    }
591    
592    public boolean getSearchSortDirectionPKHasBeenModified() {
593        return searchSortDirectionPKHasBeenModified;
594    }
595    
596    @Nonnull
597    public Long getFromTime() {
598        return fromTime;
599    }
600    
601    public void setFromTime(@Nonnull Long fromTime)
602            throws PersistenceNotNullException {
603        checkForNull(fromTime);
604        
605        boolean update = true;
606        
607        if(this.fromTime != null) {
608            if(this.fromTime.equals(fromTime)) {
609                update = false;
610            }
611        } else if(fromTime == null) {
612            update = false;
613        }
614        
615        if(update) {
616            this.fromTime = fromTime;
617            fromTimeHasBeenModified = true;
618            clearHashAndString();
619        }
620    }
621    
622    public boolean getFromTimeHasBeenModified() {
623        return fromTimeHasBeenModified;
624    }
625    
626    @Nonnull
627    public Long getThruTime() {
628        return thruTime;
629    }
630    
631    public void setThruTime(@Nonnull Long thruTime)
632            throws PersistenceNotNullException {
633        checkForNull(thruTime);
634        
635        boolean update = true;
636        
637        if(this.thruTime != null) {
638            if(this.thruTime.equals(thruTime)) {
639                update = false;
640            }
641        } else if(thruTime == null) {
642            update = false;
643        }
644        
645        if(update) {
646            this.thruTime = thruTime;
647            thruTimeHasBeenModified = true;
648            clearHashAndString();
649        }
650    }
651    
652    public boolean getThruTimeHasBeenModified() {
653        return thruTimeHasBeenModified;
654    }
655    
656}