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 * 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            StringBuilder stringValue = new StringBuilder("{");
132            
133            stringValue.append("entityId=").append(getEntityId());
134            
135            stringValue.append(", userVisitPK=").append(getUserVisitPK());
136            stringValue.append(", searchTypePK=").append(getSearchTypePK());
137            stringValue.append(", searchPK=").append(getSearchPK());
138            
139            stringValue.append('}');
140            
141            _stringValue = stringValue.toString();
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  UserVisitSearchValue) {
155            UserVisitSearchValue that = (UserVisitSearchValue)other;
156            
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 = 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) {
175            UserVisitSearchValue that = (UserVisitSearchValue)other;
176            boolean objectsEqual = true;
177            
178            
179            if(objectsEqual) {
180                UserVisitPK thisUserVisitPK = getUserVisitPK();
181                UserVisitPK thatUserVisitPK = that.getUserVisitPK();
182                
183                if(thisUserVisitPK == null) {
184                    objectsEqual = objectsEqual && (thatUserVisitPK == null);
185                } else {
186                    objectsEqual = objectsEqual && thisUserVisitPK.equals(thatUserVisitPK);
187                }
188            }
189            
190            if(objectsEqual) {
191                SearchTypePK thisSearchTypePK = getSearchTypePK();
192                SearchTypePK thatSearchTypePK = that.getSearchTypePK();
193                
194                if(thisSearchTypePK == null) {
195                    objectsEqual = objectsEqual && (thatSearchTypePK == null);
196                } else {
197                    objectsEqual = objectsEqual && thisSearchTypePK.equals(thatSearchTypePK);
198                }
199            }
200            
201            if(objectsEqual) {
202                SearchPK thisSearchPK = getSearchPK();
203                SearchPK thatSearchPK = that.getSearchPK();
204                
205                if(thisSearchPK == null) {
206                    objectsEqual = objectsEqual && (thatSearchPK == null);
207                } else {
208                    objectsEqual = objectsEqual && thisSearchPK.equals(thatSearchPK);
209                }
210            }
211            
212            return objectsEqual;
213        } else {
214            return false;
215        }
216    }
217    
218    @Override
219    public boolean hasBeenModified() {
220        return userVisitPKHasBeenModified || searchTypePKHasBeenModified || searchPKHasBeenModified;
221    }
222    
223    @Override
224    public void clearHasBeenModified() {
225        userVisitPKHasBeenModified = false;
226        searchTypePKHasBeenModified = false;
227        searchPKHasBeenModified = false;
228    }
229    
230    public UserVisitPK getUserVisitPK() {
231        return userVisitPK;
232    }
233    
234    public void setUserVisitPK(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    public SearchTypePK getSearchTypePK() {
260        return searchTypePK;
261    }
262    
263    public void setSearchTypePK(SearchTypePK searchTypePK)
264            throws PersistenceNotNullException {
265        checkForNull(searchTypePK);
266        
267        boolean update = true;
268        
269        if(this.searchTypePK != null) {
270            if(this.searchTypePK.equals(searchTypePK)) {
271                update = false;
272            }
273        } else if(searchTypePK == null) {
274            update = false;
275        }
276        
277        if(update) {
278            this.searchTypePK = searchTypePK;
279            searchTypePKHasBeenModified = true;
280            clearHashAndString();
281        }
282    }
283    
284    public boolean getSearchTypePKHasBeenModified() {
285        return searchTypePKHasBeenModified;
286    }
287    
288    public SearchPK getSearchPK() {
289        return searchPK;
290    }
291    
292    public void setSearchPK(SearchPK searchPK)
293            throws PersistenceNotNullException {
294        checkForNull(searchPK);
295        
296        boolean update = true;
297        
298        if(this.searchPK != null) {
299            if(this.searchPK.equals(searchPK)) {
300                update = false;
301            }
302        } else if(searchPK == null) {
303            update = false;
304        }
305        
306        if(update) {
307            this.searchPK = searchPK;
308            searchPKHasBeenModified = true;
309            clearHashAndString();
310        }
311    }
312    
313    public boolean getSearchPKHasBeenModified() {
314        return searchPKHasBeenModified;
315    }
316    
317}