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