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 * 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 039import javax.annotation.Nonnull; 040import javax.annotation.Nullable; 041 042public class CachedExecutedSearchResultValue 043 extends BaseValue<CachedExecutedSearchResultPK> 044 implements Cloneable, Serializable { 045 046 private CachedExecutedSearchPK cachedExecutedSearchPK; 047 private boolean cachedExecutedSearchPKHasBeenModified = false; 048 private EntityInstancePK entityInstancePK; 049 private boolean entityInstancePKHasBeenModified = false; 050 private Integer sortOrder; 051 private boolean sortOrderHasBeenModified = false; 052 053 private transient Integer _hashCode = null; 054 private transient String _stringValue = null; 055 056 private void constructFields(CachedExecutedSearchPK cachedExecutedSearchPK, EntityInstancePK entityInstancePK, Integer sortOrder) 057 throws PersistenceNotNullException { 058 checkForNull(cachedExecutedSearchPK); 059 this.cachedExecutedSearchPK = cachedExecutedSearchPK; 060 checkForNull(entityInstancePK); 061 this.entityInstancePK = entityInstancePK; 062 checkForNull(sortOrder); 063 this.sortOrder = sortOrder; 064 } 065 066 /** Creates a new instance of CachedExecutedSearchResultValue */ 067 public CachedExecutedSearchResultValue(CachedExecutedSearchResultPK cachedExecutedSearchResultPK, CachedExecutedSearchPK cachedExecutedSearchPK, EntityInstancePK entityInstancePK, Integer sortOrder) 068 throws PersistenceNotNullException { 069 super(cachedExecutedSearchResultPK); 070 constructFields(cachedExecutedSearchPK, entityInstancePK, sortOrder); 071 } 072 073 /** Creates a new instance of CachedExecutedSearchResultValue */ 074 public CachedExecutedSearchResultValue(CachedExecutedSearchPK cachedExecutedSearchPK, EntityInstancePK entityInstancePK, Integer sortOrder) 075 throws PersistenceNotNullException { 076 super(); 077 constructFields(cachedExecutedSearchPK, entityInstancePK, sortOrder); 078 } 079 080 @Override 081 @Nonnull 082 public CachedExecutedSearchResultFactory getBaseFactoryInstance() { 083 return CachedExecutedSearchResultFactory.getInstance(); 084 } 085 086 @Override 087 @Nonnull 088 public CachedExecutedSearchResultValue clone() { 089 Object result; 090 091 try { 092 result = super.clone(); 093 } catch (CloneNotSupportedException cnse) { 094 // This shouldn't happen, fail when it does. 095 throw new PersistenceCloneException(cnse); 096 } 097 098 return (CachedExecutedSearchResultValue)result; 099 } 100 101 @Override 102 @Nonnull 103 public CachedExecutedSearchResultPK getPrimaryKey() { 104 if(_primaryKey == null) { 105 _primaryKey = new CachedExecutedSearchResultPK(entityId); 106 } 107 108 return _primaryKey; 109 } 110 111 private void clearHashAndString() { 112 _hashCode = null; 113 _stringValue = null; 114 } 115 116 @Override 117 public int hashCode() { 118 if(_hashCode == null) { 119 int hashCode = 17; 120 121 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 122 123 hashCode = 37 * hashCode + ((cachedExecutedSearchPK != null) ? cachedExecutedSearchPK.hashCode() : 0); 124 hashCode = 37 * hashCode + ((entityInstancePK != null) ? entityInstancePK.hashCode() : 0); 125 hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0); 126 127 _hashCode = hashCode; 128 } 129 130 return _hashCode; 131 } 132 133 @Override 134 @Nonnull 135 public String toString() { 136 if(_stringValue == null) { 137 _stringValue = "{" + 138 "entityId=" + getEntityId() + 139 ", cachedExecutedSearchPK=" + getCachedExecutedSearchPK() + 140 ", entityInstancePK=" + getEntityInstancePK() + 141 ", sortOrder=" + getSortOrder() + 142 "}"; 143 } 144 return _stringValue; 145 } 146 147 @Override 148 public boolean equals(Object other) { 149 if(this == other) 150 return true; 151 152 if(!hasIdentity()) 153 return false; 154 155 if(other instanceof CachedExecutedSearchResultValue that) { 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 = 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 that) { 174 boolean objectsEqual = true; 175 176 177 if(objectsEqual) { 178 CachedExecutedSearchPK thisCachedExecutedSearchPK = getCachedExecutedSearchPK(); 179 CachedExecutedSearchPK thatCachedExecutedSearchPK = that.getCachedExecutedSearchPK(); 180 181 if(thisCachedExecutedSearchPK == null) { 182 objectsEqual = objectsEqual && (thatCachedExecutedSearchPK == null); 183 } else { 184 objectsEqual = objectsEqual && thisCachedExecutedSearchPK.equals(thatCachedExecutedSearchPK); 185 } 186 } 187 188 if(objectsEqual) { 189 EntityInstancePK thisEntityInstancePK = getEntityInstancePK(); 190 EntityInstancePK thatEntityInstancePK = that.getEntityInstancePK(); 191 192 if(thisEntityInstancePK == null) { 193 objectsEqual = objectsEqual && (thatEntityInstancePK == null); 194 } else { 195 objectsEqual = objectsEqual && thisEntityInstancePK.equals(thatEntityInstancePK); 196 } 197 } 198 199 if(objectsEqual) { 200 Integer thisSortOrder = getSortOrder(); 201 Integer thatSortOrder = that.getSortOrder(); 202 203 if(thisSortOrder == null) { 204 objectsEqual = objectsEqual && (thatSortOrder == null); 205 } else { 206 objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder); 207 } 208 } 209 210 return objectsEqual; 211 } else { 212 return false; 213 } 214 } 215 216 @Override 217 public boolean hasBeenModified() { 218 return cachedExecutedSearchPKHasBeenModified || entityInstancePKHasBeenModified || sortOrderHasBeenModified; 219 } 220 221 @Override 222 public void clearHasBeenModified() { 223 cachedExecutedSearchPKHasBeenModified = false; 224 entityInstancePKHasBeenModified = false; 225 sortOrderHasBeenModified = false; 226 } 227 228 @Nonnull 229 public CachedExecutedSearchPK getCachedExecutedSearchPK() { 230 return cachedExecutedSearchPK; 231 } 232 233 public void setCachedExecutedSearchPK(@Nonnull 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 @Nonnull 259 public EntityInstancePK getEntityInstancePK() { 260 return entityInstancePK; 261 } 262 263 public void setEntityInstancePK(@Nonnull EntityInstancePK entityInstancePK) 264 throws PersistenceNotNullException { 265 checkForNull(entityInstancePK); 266 267 boolean update = true; 268 269 if(this.entityInstancePK != null) { 270 if(this.entityInstancePK.equals(entityInstancePK)) { 271 update = false; 272 } 273 } else if(entityInstancePK == null) { 274 update = false; 275 } 276 277 if(update) { 278 this.entityInstancePK = entityInstancePK; 279 entityInstancePKHasBeenModified = true; 280 clearHashAndString(); 281 } 282 } 283 284 public boolean getEntityInstancePKHasBeenModified() { 285 return entityInstancePKHasBeenModified; 286 } 287 288 @Nonnull 289 public Integer getSortOrder() { 290 return sortOrder; 291 } 292 293 public void setSortOrder(@Nonnull Integer sortOrder) 294 throws PersistenceNotNullException { 295 checkForNull(sortOrder); 296 297 boolean update = true; 298 299 if(this.sortOrder != null) { 300 if(this.sortOrder.equals(sortOrder)) { 301 update = false; 302 } 303 } else if(sortOrder == null) { 304 update = false; 305 } 306 307 if(update) { 308 this.sortOrder = sortOrder; 309 sortOrderHasBeenModified = true; 310 clearHashAndString(); 311 } 312 } 313 314 public boolean getSortOrderHasBeenModified() { 315 return sortOrderHasBeenModified; 316 } 317 318}