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