001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 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 * SearchValue.java
021 */
022
023package com.echothree.model.data.search.server.value;
024
025import com.echothree.model.data.search.common.pk.SearchPK;
026
027import com.echothree.model.data.search.server.factory.SearchFactory;
028
029import com.echothree.model.data.party.common.pk.PartyPK;
030import com.echothree.model.data.search.common.pk.SearchTypePK;
031import com.echothree.model.data.search.common.pk.SearchUseTypePK;
032import com.echothree.model.data.search.common.pk.CachedSearchPK;
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
041public class SearchValue
042        extends BaseValue<SearchPK>
043        implements Cloneable, Serializable {
044    
045    private PartyPK partyPK;
046    private boolean partyPKHasBeenModified = false;
047    private Boolean partyVerified;
048    private boolean partyVerifiedHasBeenModified = false;
049    private SearchTypePK searchTypePK;
050    private boolean searchTypePKHasBeenModified = false;
051    private Long executedTime;
052    private boolean executedTimeHasBeenModified = false;
053    private SearchUseTypePK searchUseTypePK;
054    private boolean searchUseTypePKHasBeenModified = false;
055    private CachedSearchPK cachedSearchPK;
056    private boolean cachedSearchPKHasBeenModified = false;
057    private Long fromTime;
058    private boolean fromTimeHasBeenModified = false;
059    private Long thruTime;
060    private boolean thruTimeHasBeenModified = false;
061    
062    private transient Integer _hashCode = null;
063    private transient String _stringValue = null;
064    
065    private void constructFields(PartyPK partyPK, Boolean partyVerified, SearchTypePK searchTypePK, Long executedTime, SearchUseTypePK searchUseTypePK, CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
066            throws PersistenceNotNullException {
067        this.partyPK = partyPK;
068        this.partyVerified = partyVerified;
069        checkForNull(searchTypePK);
070        this.searchTypePK = searchTypePK;
071        checkForNull(executedTime);
072        this.executedTime = executedTime;
073        this.searchUseTypePK = searchUseTypePK;
074        this.cachedSearchPK = cachedSearchPK;
075        checkForNull(fromTime);
076        this.fromTime = fromTime;
077        checkForNull(thruTime);
078        this.thruTime = thruTime;
079    }
080    
081    /** Creates a new instance of SearchValue */
082    public SearchValue(SearchPK searchPK, PartyPK partyPK, Boolean partyVerified, SearchTypePK searchTypePK, Long executedTime, SearchUseTypePK searchUseTypePK, CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
083            throws PersistenceNotNullException {
084        super(searchPK);
085        constructFields(partyPK, partyVerified, searchTypePK, executedTime, searchUseTypePK, cachedSearchPK, fromTime, thruTime);
086    }
087    
088    /** Creates a new instance of SearchValue */
089    public SearchValue(PartyPK partyPK, Boolean partyVerified, SearchTypePK searchTypePK, Long executedTime, SearchUseTypePK searchUseTypePK, CachedSearchPK cachedSearchPK, Long fromTime, Long thruTime)
090            throws PersistenceNotNullException {
091        super();
092        constructFields(partyPK, partyVerified, searchTypePK, executedTime, searchUseTypePK, cachedSearchPK, fromTime, thruTime);
093    }
094    
095   @Override
096   public SearchFactory getBaseFactoryInstance() {
097        return SearchFactory.getInstance();
098    }
099    
100    @Override
101    public SearchValue clone() {
102        Object result;
103        
104        try {
105            result = super.clone();
106        } catch (CloneNotSupportedException cnse) {
107            // This shouldn't happen, fail when it does.
108            throw new PersistenceCloneException(cnse);
109        }
110        
111        return (SearchValue)result;
112    }
113    
114   @Override
115    public SearchPK getPrimaryKey() {
116        if(_primaryKey == null) {
117            _primaryKey = new SearchPK(entityId);
118        }
119        
120        return _primaryKey;
121    }
122    
123    private void clearHashAndString() {
124        _hashCode = null;
125        _stringValue = null;
126    }
127    
128    @Override
129    public int hashCode() {
130        if(_hashCode == null) {
131            int hashCode = 17;
132            
133            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
134            
135            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
136            hashCode = 37 * hashCode + ((partyVerified != null) ? partyVerified.hashCode() : 0);
137            hashCode = 37 * hashCode + ((searchTypePK != null) ? searchTypePK.hashCode() : 0);
138            hashCode = 37 * hashCode + ((executedTime != null) ? executedTime.hashCode() : 0);
139            hashCode = 37 * hashCode + ((searchUseTypePK != null) ? searchUseTypePK.hashCode() : 0);
140            hashCode = 37 * hashCode + ((cachedSearchPK != null) ? cachedSearchPK.hashCode() : 0);
141            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
142            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
143            
144            _hashCode = hashCode;
145        }
146        
147        return _hashCode;
148    }
149    
150    @Override
151    public String toString() {
152        if(_stringValue == null) {
153            StringBuilder stringValue = new StringBuilder("{");
154            
155            stringValue.append("entityId=").append(getEntityId());
156            
157            stringValue.append(", partyPK=").append(getPartyPK());
158            stringValue.append(", partyVerified=").append(getPartyVerified());
159            stringValue.append(", searchTypePK=").append(getSearchTypePK());
160            stringValue.append(", executedTime=").append(getExecutedTime());
161            stringValue.append(", searchUseTypePK=").append(getSearchUseTypePK());
162            stringValue.append(", cachedSearchPK=").append(getCachedSearchPK());
163            stringValue.append(", fromTime=").append(getFromTime());
164            stringValue.append(", thruTime=").append(getThruTime());
165            
166            stringValue.append('}');
167            
168            _stringValue = stringValue.toString();
169        }
170        return _stringValue;
171    }
172    
173    @Override
174    public boolean equals(Object other) {
175        if(this == other)
176            return true;
177        
178        if(!hasIdentity())
179            return false;
180        
181        if(other instanceof  SearchValue) {
182            SearchValue that = (SearchValue)other;
183            
184            if(!that.hasIdentity())
185                return false;
186            
187            Long thisEntityId = getEntityId();
188            Long thatEntityId = that.getEntityId();
189            
190            boolean objectsEqual = thisEntityId.equals(thatEntityId);
191            if(objectsEqual)
192                objectsEqual = objectsEqual && isIdentical(that);
193            
194            return objectsEqual;
195        } else {
196            return false;
197        }
198    }
199    
200    public boolean isIdentical(Object other) {
201        if(other instanceof SearchValue) {
202            SearchValue that = (SearchValue)other;
203            boolean objectsEqual = true;
204            
205            
206            if(objectsEqual) {
207                PartyPK thisPartyPK = getPartyPK();
208                PartyPK thatPartyPK = that.getPartyPK();
209                
210                if(thisPartyPK == null) {
211                    objectsEqual = objectsEqual && (thatPartyPK == null);
212                } else {
213                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
214                }
215            }
216            
217            if(objectsEqual) {
218                Boolean thisPartyVerified = getPartyVerified();
219                Boolean thatPartyVerified = that.getPartyVerified();
220                
221                if(thisPartyVerified == null) {
222                    objectsEqual = objectsEqual && (thatPartyVerified == null);
223                } else {
224                    objectsEqual = objectsEqual && thisPartyVerified.equals(thatPartyVerified);
225                }
226            }
227            
228            if(objectsEqual) {
229                SearchTypePK thisSearchTypePK = getSearchTypePK();
230                SearchTypePK thatSearchTypePK = that.getSearchTypePK();
231                
232                if(thisSearchTypePK == null) {
233                    objectsEqual = objectsEqual && (thatSearchTypePK == null);
234                } else {
235                    objectsEqual = objectsEqual && thisSearchTypePK.equals(thatSearchTypePK);
236                }
237            }
238            
239            if(objectsEqual) {
240                Long thisExecutedTime = getExecutedTime();
241                Long thatExecutedTime = that.getExecutedTime();
242                
243                if(thisExecutedTime == null) {
244                    objectsEqual = objectsEqual && (thatExecutedTime == null);
245                } else {
246                    objectsEqual = objectsEqual && thisExecutedTime.equals(thatExecutedTime);
247                }
248            }
249            
250            if(objectsEqual) {
251                SearchUseTypePK thisSearchUseTypePK = getSearchUseTypePK();
252                SearchUseTypePK thatSearchUseTypePK = that.getSearchUseTypePK();
253                
254                if(thisSearchUseTypePK == null) {
255                    objectsEqual = objectsEqual && (thatSearchUseTypePK == null);
256                } else {
257                    objectsEqual = objectsEqual && thisSearchUseTypePK.equals(thatSearchUseTypePK);
258                }
259            }
260            
261            if(objectsEqual) {
262                CachedSearchPK thisCachedSearchPK = getCachedSearchPK();
263                CachedSearchPK thatCachedSearchPK = that.getCachedSearchPK();
264                
265                if(thisCachedSearchPK == null) {
266                    objectsEqual = objectsEqual && (thatCachedSearchPK == null);
267                } else {
268                    objectsEqual = objectsEqual && thisCachedSearchPK.equals(thatCachedSearchPK);
269                }
270            }
271            
272            if(objectsEqual) {
273                Long thisFromTime = getFromTime();
274                Long thatFromTime = that.getFromTime();
275                
276                if(thisFromTime == null) {
277                    objectsEqual = objectsEqual && (thatFromTime == null);
278                } else {
279                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
280                }
281            }
282            
283            if(objectsEqual) {
284                Long thisThruTime = getThruTime();
285                Long thatThruTime = that.getThruTime();
286                
287                if(thisThruTime == null) {
288                    objectsEqual = objectsEqual && (thatThruTime == null);
289                } else {
290                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
291                }
292            }
293            
294            return objectsEqual;
295        } else {
296            return false;
297        }
298    }
299    
300    @Override
301    public boolean hasBeenModified() {
302        return partyPKHasBeenModified || partyVerifiedHasBeenModified || searchTypePKHasBeenModified || executedTimeHasBeenModified || searchUseTypePKHasBeenModified || cachedSearchPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
303    }
304    
305    @Override
306    public void clearHasBeenModified() {
307        partyPKHasBeenModified = false;
308        partyVerifiedHasBeenModified = false;
309        searchTypePKHasBeenModified = false;
310        executedTimeHasBeenModified = false;
311        searchUseTypePKHasBeenModified = false;
312        cachedSearchPKHasBeenModified = false;
313        fromTimeHasBeenModified = false;
314        thruTimeHasBeenModified = false;
315    }
316    
317    public PartyPK getPartyPK() {
318        return partyPK;
319    }
320    
321    public void setPartyPK(PartyPK partyPK) {
322        boolean update = true;
323        
324        if(this.partyPK != null) {
325            if(this.partyPK.equals(partyPK)) {
326                update = false;
327            }
328        } else if(partyPK == null) {
329            update = false;
330        }
331        
332        if(update) {
333            this.partyPK = partyPK;
334            partyPKHasBeenModified = true;
335            clearHashAndString();
336        }
337    }
338    
339    public boolean getPartyPKHasBeenModified() {
340        return partyPKHasBeenModified;
341    }
342    
343    public Boolean getPartyVerified() {
344        return partyVerified;
345    }
346    
347    public void setPartyVerified(Boolean partyVerified) {
348        boolean update = true;
349        
350        if(this.partyVerified != null) {
351            if(this.partyVerified.equals(partyVerified)) {
352                update = false;
353            }
354        } else if(partyVerified == null) {
355            update = false;
356        }
357        
358        if(update) {
359            this.partyVerified = partyVerified;
360            partyVerifiedHasBeenModified = true;
361            clearHashAndString();
362        }
363    }
364    
365    public boolean getPartyVerifiedHasBeenModified() {
366        return partyVerifiedHasBeenModified;
367    }
368    
369    public SearchTypePK getSearchTypePK() {
370        return searchTypePK;
371    }
372    
373    public void setSearchTypePK(SearchTypePK searchTypePK)
374            throws PersistenceNotNullException {
375        checkForNull(searchTypePK);
376        
377        boolean update = true;
378        
379        if(this.searchTypePK != null) {
380            if(this.searchTypePK.equals(searchTypePK)) {
381                update = false;
382            }
383        } else if(searchTypePK == null) {
384            update = false;
385        }
386        
387        if(update) {
388            this.searchTypePK = searchTypePK;
389            searchTypePKHasBeenModified = true;
390            clearHashAndString();
391        }
392    }
393    
394    public boolean getSearchTypePKHasBeenModified() {
395        return searchTypePKHasBeenModified;
396    }
397    
398    public Long getExecutedTime() {
399        return executedTime;
400    }
401    
402    public void setExecutedTime(Long executedTime)
403            throws PersistenceNotNullException {
404        checkForNull(executedTime);
405        
406        boolean update = true;
407        
408        if(this.executedTime != null) {
409            if(this.executedTime.equals(executedTime)) {
410                update = false;
411            }
412        } else if(executedTime == null) {
413            update = false;
414        }
415        
416        if(update) {
417            this.executedTime = executedTime;
418            executedTimeHasBeenModified = true;
419            clearHashAndString();
420        }
421    }
422    
423    public boolean getExecutedTimeHasBeenModified() {
424        return executedTimeHasBeenModified;
425    }
426    
427    public SearchUseTypePK getSearchUseTypePK() {
428        return searchUseTypePK;
429    }
430    
431    public void setSearchUseTypePK(SearchUseTypePK searchUseTypePK) {
432        boolean update = true;
433        
434        if(this.searchUseTypePK != null) {
435            if(this.searchUseTypePK.equals(searchUseTypePK)) {
436                update = false;
437            }
438        } else if(searchUseTypePK == null) {
439            update = false;
440        }
441        
442        if(update) {
443            this.searchUseTypePK = searchUseTypePK;
444            searchUseTypePKHasBeenModified = true;
445            clearHashAndString();
446        }
447    }
448    
449    public boolean getSearchUseTypePKHasBeenModified() {
450        return searchUseTypePKHasBeenModified;
451    }
452    
453    public CachedSearchPK getCachedSearchPK() {
454        return cachedSearchPK;
455    }
456    
457    public void setCachedSearchPK(CachedSearchPK cachedSearchPK) {
458        boolean update = true;
459        
460        if(this.cachedSearchPK != null) {
461            if(this.cachedSearchPK.equals(cachedSearchPK)) {
462                update = false;
463            }
464        } else if(cachedSearchPK == null) {
465            update = false;
466        }
467        
468        if(update) {
469            this.cachedSearchPK = cachedSearchPK;
470            cachedSearchPKHasBeenModified = true;
471            clearHashAndString();
472        }
473    }
474    
475    public boolean getCachedSearchPKHasBeenModified() {
476        return cachedSearchPKHasBeenModified;
477    }
478    
479    public Long getFromTime() {
480        return fromTime;
481    }
482    
483    public void setFromTime(Long fromTime)
484            throws PersistenceNotNullException {
485        checkForNull(fromTime);
486        
487        boolean update = true;
488        
489        if(this.fromTime != null) {
490            if(this.fromTime.equals(fromTime)) {
491                update = false;
492            }
493        } else if(fromTime == null) {
494            update = false;
495        }
496        
497        if(update) {
498            this.fromTime = fromTime;
499            fromTimeHasBeenModified = true;
500            clearHashAndString();
501        }
502    }
503    
504    public boolean getFromTimeHasBeenModified() {
505        return fromTimeHasBeenModified;
506    }
507    
508    public Long getThruTime() {
509        return thruTime;
510    }
511    
512    public void setThruTime(Long thruTime)
513            throws PersistenceNotNullException {
514        checkForNull(thruTime);
515        
516        boolean update = true;
517        
518        if(this.thruTime != null) {
519            if(this.thruTime.equals(thruTime)) {
520                update = false;
521            }
522        } else if(thruTime == null) {
523            update = false;
524        }
525        
526        if(update) {
527            this.thruTime = thruTime;
528            thruTimeHasBeenModified = true;
529            clearHashAndString();
530        }
531    }
532    
533    public boolean getThruTimeHasBeenModified() {
534        return thruTimeHasBeenModified;
535    }
536    
537}