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