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 * 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 _stringValue = "{" + 131 "entityId=" + getEntityId() + 132 ", cachedExecutedSearchPK=" + getCachedExecutedSearchPK() + 133 ", entityInstancePK=" + getEntityInstancePK() + 134 ", sortOrder=" + getSortOrder() + 135 "}"; 136 } 137 return _stringValue; 138 } 139 140 @Override 141 public boolean equals(Object other) { 142 if(this == other) 143 return true; 144 145 if(!hasIdentity()) 146 return false; 147 148 if(other instanceof CachedExecutedSearchResultValue that) { 149 if(!that.hasIdentity()) 150 return false; 151 152 Long thisEntityId = getEntityId(); 153 Long thatEntityId = that.getEntityId(); 154 155 boolean objectsEqual = thisEntityId.equals(thatEntityId); 156 if(objectsEqual) 157 objectsEqual = isIdentical(that); 158 159 return objectsEqual; 160 } else { 161 return false; 162 } 163 } 164 165 public boolean isIdentical(Object other) { 166 if(other instanceof CachedExecutedSearchResultValue that) { 167 boolean objectsEqual = true; 168 169 170 if(objectsEqual) { 171 CachedExecutedSearchPK thisCachedExecutedSearchPK = getCachedExecutedSearchPK(); 172 CachedExecutedSearchPK thatCachedExecutedSearchPK = that.getCachedExecutedSearchPK(); 173 174 if(thisCachedExecutedSearchPK == null) { 175 objectsEqual = objectsEqual && (thatCachedExecutedSearchPK == null); 176 } else { 177 objectsEqual = objectsEqual && thisCachedExecutedSearchPK.equals(thatCachedExecutedSearchPK); 178 } 179 } 180 181 if(objectsEqual) { 182 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 183 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 184 185 if(thisEntityInstancePK == null) { 186 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 187 } else { 188 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 189 } 190 } 191 192 if(objectsEqual) { 193 Integer thisSortOrder = getSortOrder(); 194 Integer thatSortOrder = that.getSortOrder(); 195 196 if(thisSortOrder == null) { 197 objectsEqual = objectsEqual && (thatSortOrder == null); 198 } else { 199 objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder); 200 } 201 } 202 203 return objectsEqual; 204 } else { 205 return false; 206 } 207 } 208 209 @Override 210 public boolean hasBeenModified() { 211 return cachedExecutedSearchPKHasBeenModified || entityInstancePKHasBeenModified || sortOrderHasBeenModified; 212 } 213 214 @Override 215 public void clearHasBeenModified() { 216 cachedExecutedSearchPKHasBeenModified = false; 217 entityInstancePKHasBeenModified = false; 218 sortOrderHasBeenModified = false; 219 } 220 221 public CachedExecutedSearchPK getCachedExecutedSearchPK() { 222 return cachedExecutedSearchPK; 223 } 224 225 public void setCachedExecutedSearchPK(CachedExecutedSearchPK cachedExecutedSearchPK) 226 throws PersistenceNotNullException { 227 checkForNull(cachedExecutedSearchPK); 228 229 boolean update = true; 230 231 if(this.cachedExecutedSearchPK != null) { 232 if(this.cachedExecutedSearchPK.equals(cachedExecutedSearchPK)) { 233 update = false; 234 } 235 } else if(cachedExecutedSearchPK == null) { 236 update = false; 237 } 238 239 if(update) { 240 this.cachedExecutedSearchPK = cachedExecutedSearchPK; 241 cachedExecutedSearchPKHasBeenModified = true; 242 clearHashAndString(); 243 } 244 } 245 246 public boolean getCachedExecutedSearchPKHasBeenModified() { 247 return cachedExecutedSearchPKHasBeenModified; 248 } 249 250 public EntityInstancePK getEntityInstancePK() { 251 return entityInstancePK; 252 } 253 254 public void setEntityInstancePK(EntityInstancePK entityInstancePK) 255 throws PersistenceNotNullException { 256 checkForNull(entityInstancePK); 257 258 boolean update = true; 259 260 if(this.entityInstancePK != null) { 261 if(this.entityInstancePK.equals(entityInstancePK)) { 262 update = false; 263 } 264 } else if(entityInstancePK == null) { 265 update = false; 266 } 267 268 if(update) { 269 this.entityInstancePK = entityInstancePK; 270 entityInstancePKHasBeenModified = true; 271 clearHashAndString(); 272 } 273 } 274 275 public boolean getEntityInstancePKHasBeenModified() { 276 return entityInstancePKHasBeenModified; 277 } 278 279 public Integer getSortOrder() { 280 return sortOrder; 281 } 282 283 public void setSortOrder(Integer sortOrder) 284 throws PersistenceNotNullException { 285 checkForNull(sortOrder); 286 287 boolean update = true; 288 289 if(this.sortOrder != null) { 290 if(this.sortOrder.equals(sortOrder)) { 291 update = false; 292 } 293 } else if(sortOrder == null) { 294 update = false; 295 } 296 297 if(update) { 298 this.sortOrder = sortOrder; 299 sortOrderHasBeenModified = true; 300 clearHashAndString(); 301 } 302 } 303 304 public boolean getSortOrderHasBeenModified() { 305 return sortOrderHasBeenModified; 306 } 307 308}