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 * CachedSearchValue.java 021 */ 022 023package com.echothree.model.data.search.server.value; 024 025import com.echothree.model.data.search.common.pk.CachedSearchPK; 026 027import com.echothree.model.data.search.server.factory.CachedSearchFactory; 028 029import com.echothree.model.data.index.common.pk.IndexPK; 030import com.echothree.model.data.search.common.pk.SearchDefaultOperatorPK; 031import com.echothree.model.data.search.common.pk.SearchSortOrderPK; 032import com.echothree.model.data.search.common.pk.SearchSortDirectionPK; 033 034import com.echothree.util.common.exception.PersistenceCloneException; 035import com.echothree.util.common.exception.PersistenceNotNullException; 036 037import com.echothree.util.server.persistence.BaseValue; 038 039import java.io.Serializable; 040 041public class CachedSearchValue 042 extends BaseValue<CachedSearchPK> 043 implements Cloneable, Serializable { 044 045 private IndexPK indexPK; 046 private boolean indexPKHasBeenModified = false; 047 private String querySha1Hash; 048 private boolean querySha1HashHasBeenModified = false; 049 private String query; 050 private boolean queryHasBeenModified = false; 051 private String parsedQuerySha1Hash; 052 private boolean parsedQuerySha1HashHasBeenModified = false; 053 private String parsedQuery; 054 private boolean parsedQueryHasBeenModified = false; 055 private SearchDefaultOperatorPK searchDefaultOperatorPK; 056 private boolean searchDefaultOperatorPKHasBeenModified = false; 057 private SearchSortOrderPK searchSortOrderPK; 058 private boolean searchSortOrderPKHasBeenModified = false; 059 private SearchSortDirectionPK searchSortDirectionPK; 060 private boolean searchSortDirectionPKHasBeenModified = false; 061 private Long fromTime; 062 private boolean fromTimeHasBeenModified = false; 063 private Long thruTime; 064 private boolean thruTimeHasBeenModified = false; 065 066 private transient Integer _hashCode = null; 067 private transient String _stringValue = null; 068 069 private void constructFields(IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime) 070 throws PersistenceNotNullException { 071 checkForNull(indexPK); 072 this.indexPK = indexPK; 073 checkForNull(querySha1Hash); 074 this.querySha1Hash = querySha1Hash; 075 checkForNull(query); 076 this.query = query; 077 checkForNull(parsedQuerySha1Hash); 078 this.parsedQuerySha1Hash = parsedQuerySha1Hash; 079 checkForNull(parsedQuery); 080 this.parsedQuery = parsedQuery; 081 checkForNull(searchDefaultOperatorPK); 082 this.searchDefaultOperatorPK = searchDefaultOperatorPK; 083 checkForNull(searchSortOrderPK); 084 this.searchSortOrderPK = searchSortOrderPK; 085 checkForNull(searchSortDirectionPK); 086 this.searchSortDirectionPK = searchSortDirectionPK; 087 checkForNull(fromTime); 088 this.fromTime = fromTime; 089 checkForNull(thruTime); 090 this.thruTime = thruTime; 091 } 092 093 /** Creates a new instance of CachedSearchValue */ 094 public CachedSearchValue(CachedSearchPK cachedSearchPK, IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime) 095 throws PersistenceNotNullException { 096 super(cachedSearchPK); 097 constructFields(indexPK, querySha1Hash, query, parsedQuerySha1Hash, parsedQuery, searchDefaultOperatorPK, searchSortOrderPK, searchSortDirectionPK, fromTime, thruTime); 098 } 099 100 /** Creates a new instance of CachedSearchValue */ 101 public CachedSearchValue(IndexPK indexPK, String querySha1Hash, String query, String parsedQuerySha1Hash, String parsedQuery, SearchDefaultOperatorPK searchDefaultOperatorPK, SearchSortOrderPK searchSortOrderPK, SearchSortDirectionPK searchSortDirectionPK, Long fromTime, Long thruTime) 102 throws PersistenceNotNullException { 103 super(); 104 constructFields(indexPK, querySha1Hash, query, parsedQuerySha1Hash, parsedQuery, searchDefaultOperatorPK, searchSortOrderPK, searchSortDirectionPK, fromTime, thruTime); 105 } 106 107 @Override 108 public CachedSearchFactory getBaseFactoryInstance() { 109 return CachedSearchFactory.getInstance(); 110 } 111 112 @Override 113 public CachedSearchValue clone() { 114 Object result; 115 116 try { 117 result = super.clone(); 118 } catch (CloneNotSupportedException cnse) { 119 // This shouldn't happen, fail when it does. 120 throw new PersistenceCloneException(cnse); 121 } 122 123 return (CachedSearchValue)result; 124 } 125 126 @Override 127 public CachedSearchPK getPrimaryKey() { 128 if(_primaryKey == null) { 129 _primaryKey = new CachedSearchPK(entityId); 130 } 131 132 return _primaryKey; 133 } 134 135 private void clearHashAndString() { 136 _hashCode = null; 137 _stringValue = null; 138 } 139 140 @Override 141 public int hashCode() { 142 if(_hashCode == null) { 143 int hashCode = 17; 144 145 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 146 147 hashCode = 37 * hashCode + ((indexPK != null) ? indexPK.hashCode() : 0); 148 hashCode = 37 * hashCode + ((querySha1Hash != null) ? querySha1Hash.hashCode() : 0); 149 hashCode = 37 * hashCode + ((query != null) ? query.hashCode() : 0); 150 hashCode = 37 * hashCode + ((parsedQuerySha1Hash != null) ? parsedQuerySha1Hash.hashCode() : 0); 151 hashCode = 37 * hashCode + ((parsedQuery != null) ? parsedQuery.hashCode() : 0); 152 hashCode = 37 * hashCode + ((searchDefaultOperatorPK != null) ? searchDefaultOperatorPK.hashCode() : 0); 153 hashCode = 37 * hashCode + ((searchSortOrderPK != null) ? searchSortOrderPK.hashCode() : 0); 154 hashCode = 37 * hashCode + ((searchSortDirectionPK != null) ? searchSortDirectionPK.hashCode() : 0); 155 hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0); 156 hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0); 157 158 _hashCode = hashCode; 159 } 160 161 return _hashCode; 162 } 163 164 @Override 165 public String toString() { 166 if(_stringValue == null) { 167 _stringValue = "{" + 168 "entityId=" + getEntityId() + 169 ", indexPK=" + getIndexPK() + 170 ", querySha1Hash=" + getQuerySha1Hash() + 171 ", query=" + getQuery() + 172 ", parsedQuerySha1Hash=" + getParsedQuerySha1Hash() + 173 ", parsedQuery=" + getParsedQuery() + 174 ", searchDefaultOperatorPK=" + getSearchDefaultOperatorPK() + 175 ", searchSortOrderPK=" + getSearchSortOrderPK() + 176 ", searchSortDirectionPK=" + getSearchSortDirectionPK() + 177 ", fromTime=" + getFromTime() + 178 ", thruTime=" + getThruTime() + 179 "}"; 180 } 181 return _stringValue; 182 } 183 184 @Override 185 public boolean equals(Object other) { 186 if(this == other) 187 return true; 188 189 if(!hasIdentity()) 190 return false; 191 192 if(other instanceof CachedSearchValue that) { 193 if(!that.hasIdentity()) 194 return false; 195 196 Long thisEntityId = getEntityId(); 197 Long thatEntityId = that.getEntityId(); 198 199 boolean objectsEqual = thisEntityId.equals(thatEntityId); 200 if(objectsEqual) 201 objectsEqual = isIdentical(that); 202 203 return objectsEqual; 204 } else { 205 return false; 206 } 207 } 208 209 public boolean isIdentical(Object other) { 210 if(other instanceof CachedSearchValue that) { 211 boolean objectsEqual = true; 212 213 214 if(objectsEqual) { 215 IndexPK thisIndexPK = getIndexPK(); 216 IndexPK thatIndexPK = that.getIndexPK(); 217 218 if(thisIndexPK == null) { 219 objectsEqual = objectsEqual && (thatIndexPK == null); 220 } else { 221 objectsEqual = objectsEqual && thisIndexPK.equals(thatIndexPK); 222 } 223 } 224 225 if(objectsEqual) { 226 String thisQuerySha1Hash = getQuerySha1Hash(); 227 String thatQuerySha1Hash = that.getQuerySha1Hash(); 228 229 if(thisQuerySha1Hash == null) { 230 objectsEqual = objectsEqual && (thatQuerySha1Hash == null); 231 } else { 232 objectsEqual = objectsEqual && thisQuerySha1Hash.equals(thatQuerySha1Hash); 233 } 234 } 235 236 if(objectsEqual) { 237 String thisQuery = getQuery(); 238 String thatQuery = that.getQuery(); 239 240 if(thisQuery == null) { 241 objectsEqual = objectsEqual && (thatQuery == null); 242 } else { 243 objectsEqual = objectsEqual && thisQuery.equals(thatQuery); 244 } 245 } 246 247 if(objectsEqual) { 248 String thisParsedQuerySha1Hash = getParsedQuerySha1Hash(); 249 String thatParsedQuerySha1Hash = that.getParsedQuerySha1Hash(); 250 251 if(thisParsedQuerySha1Hash == null) { 252 objectsEqual = objectsEqual && (thatParsedQuerySha1Hash == null); 253 } else { 254 objectsEqual = objectsEqual && thisParsedQuerySha1Hash.equals(thatParsedQuerySha1Hash); 255 } 256 } 257 258 if(objectsEqual) { 259 String thisParsedQuery = getParsedQuery(); 260 String thatParsedQuery = that.getParsedQuery(); 261 262 if(thisParsedQuery == null) { 263 objectsEqual = objectsEqual && (thatParsedQuery == null); 264 } else { 265 objectsEqual = objectsEqual && thisParsedQuery.equals(thatParsedQuery); 266 } 267 } 268 269 if(objectsEqual) { 270 SearchDefaultOperatorPK thisSearchDefaultOperatorPK = getSearchDefaultOperatorPK(); 271 SearchDefaultOperatorPK thatSearchDefaultOperatorPK = that.getSearchDefaultOperatorPK(); 272 273 if(thisSearchDefaultOperatorPK == null) { 274 objectsEqual = objectsEqual && (thatSearchDefaultOperatorPK == null); 275 } else { 276 objectsEqual = objectsEqual && thisSearchDefaultOperatorPK.equals(thatSearchDefaultOperatorPK); 277 } 278 } 279 280 if(objectsEqual) { 281 SearchSortOrderPK thisSearchSortOrderPK = getSearchSortOrderPK(); 282 SearchSortOrderPK thatSearchSortOrderPK = that.getSearchSortOrderPK(); 283 284 if(thisSearchSortOrderPK == null) { 285 objectsEqual = objectsEqual && (thatSearchSortOrderPK == null); 286 } else { 287 objectsEqual = objectsEqual && thisSearchSortOrderPK.equals(thatSearchSortOrderPK); 288 } 289 } 290 291 if(objectsEqual) { 292 SearchSortDirectionPK thisSearchSortDirectionPK = getSearchSortDirectionPK(); 293 SearchSortDirectionPK thatSearchSortDirectionPK = that.getSearchSortDirectionPK(); 294 295 if(thisSearchSortDirectionPK == null) { 296 objectsEqual = objectsEqual && (thatSearchSortDirectionPK == null); 297 } else { 298 objectsEqual = objectsEqual && thisSearchSortDirectionPK.equals(thatSearchSortDirectionPK); 299 } 300 } 301 302 if(objectsEqual) { 303 Long thisFromTime = getFromTime(); 304 Long thatFromTime = that.getFromTime(); 305 306 if(thisFromTime == null) { 307 objectsEqual = objectsEqual && (thatFromTime == null); 308 } else { 309 objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime); 310 } 311 } 312 313 if(objectsEqual) { 314 Long thisThruTime = getThruTime(); 315 Long thatThruTime = that.getThruTime(); 316 317 if(thisThruTime == null) { 318 objectsEqual = objectsEqual && (thatThruTime == null); 319 } else { 320 objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime); 321 } 322 } 323 324 return objectsEqual; 325 } else { 326 return false; 327 } 328 } 329 330 @Override 331 public boolean hasBeenModified() { 332 return indexPKHasBeenModified || querySha1HashHasBeenModified || queryHasBeenModified || parsedQuerySha1HashHasBeenModified || parsedQueryHasBeenModified || searchDefaultOperatorPKHasBeenModified || searchSortOrderPKHasBeenModified || searchSortDirectionPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified; 333 } 334 335 @Override 336 public void clearHasBeenModified() { 337 indexPKHasBeenModified = false; 338 querySha1HashHasBeenModified = false; 339 queryHasBeenModified = false; 340 parsedQuerySha1HashHasBeenModified = false; 341 parsedQueryHasBeenModified = false; 342 searchDefaultOperatorPKHasBeenModified = false; 343 searchSortOrderPKHasBeenModified = false; 344 searchSortDirectionPKHasBeenModified = false; 345 fromTimeHasBeenModified = false; 346 thruTimeHasBeenModified = false; 347 } 348 349 public IndexPK getIndexPK() { 350 return indexPK; 351 } 352 353 public void setIndexPK(IndexPK indexPK) 354 throws PersistenceNotNullException { 355 checkForNull(indexPK); 356 357 boolean update = true; 358 359 if(this.indexPK != null) { 360 if(this.indexPK.equals(indexPK)) { 361 update = false; 362 } 363 } else if(indexPK == null) { 364 update = false; 365 } 366 367 if(update) { 368 this.indexPK = indexPK; 369 indexPKHasBeenModified = true; 370 clearHashAndString(); 371 } 372 } 373 374 public boolean getIndexPKHasBeenModified() { 375 return indexPKHasBeenModified; 376 } 377 378 public String getQuerySha1Hash() { 379 return querySha1Hash; 380 } 381 382 public void setQuerySha1Hash(String querySha1Hash) 383 throws PersistenceNotNullException { 384 checkForNull(querySha1Hash); 385 386 boolean update = true; 387 388 if(this.querySha1Hash != null) { 389 if(this.querySha1Hash.equals(querySha1Hash)) { 390 update = false; 391 } 392 } else if(querySha1Hash == null) { 393 update = false; 394 } 395 396 if(update) { 397 this.querySha1Hash = querySha1Hash; 398 querySha1HashHasBeenModified = true; 399 clearHashAndString(); 400 } 401 } 402 403 public boolean getQuerySha1HashHasBeenModified() { 404 return querySha1HashHasBeenModified; 405 } 406 407 public String getQuery() { 408 return query; 409 } 410 411 public void setQuery(String query) 412 throws PersistenceNotNullException { 413 checkForNull(query); 414 415 boolean update = true; 416 417 if(this.query != null) { 418 if(this.query.equals(query)) { 419 update = false; 420 } 421 } else if(query == null) { 422 update = false; 423 } 424 425 if(update) { 426 this.query = query; 427 queryHasBeenModified = true; 428 clearHashAndString(); 429 } 430 } 431 432 public boolean getQueryHasBeenModified() { 433 return queryHasBeenModified; 434 } 435 436 public String getParsedQuerySha1Hash() { 437 return parsedQuerySha1Hash; 438 } 439 440 public void setParsedQuerySha1Hash(String parsedQuerySha1Hash) 441 throws PersistenceNotNullException { 442 checkForNull(parsedQuerySha1Hash); 443 444 boolean update = true; 445 446 if(this.parsedQuerySha1Hash != null) { 447 if(this.parsedQuerySha1Hash.equals(parsedQuerySha1Hash)) { 448 update = false; 449 } 450 } else if(parsedQuerySha1Hash == null) { 451 update = false; 452 } 453 454 if(update) { 455 this.parsedQuerySha1Hash = parsedQuerySha1Hash; 456 parsedQuerySha1HashHasBeenModified = true; 457 clearHashAndString(); 458 } 459 } 460 461 public boolean getParsedQuerySha1HashHasBeenModified() { 462 return parsedQuerySha1HashHasBeenModified; 463 } 464 465 public String getParsedQuery() { 466 return parsedQuery; 467 } 468 469 public void setParsedQuery(String parsedQuery) 470 throws PersistenceNotNullException { 471 checkForNull(parsedQuery); 472 473 boolean update = true; 474 475 if(this.parsedQuery != null) { 476 if(this.parsedQuery.equals(parsedQuery)) { 477 update = false; 478 } 479 } else if(parsedQuery == null) { 480 update = false; 481 } 482 483 if(update) { 484 this.parsedQuery = parsedQuery; 485 parsedQueryHasBeenModified = true; 486 clearHashAndString(); 487 } 488 } 489 490 public boolean getParsedQueryHasBeenModified() { 491 return parsedQueryHasBeenModified; 492 } 493 494 public SearchDefaultOperatorPK getSearchDefaultOperatorPK() { 495 return searchDefaultOperatorPK; 496 } 497 498 public void setSearchDefaultOperatorPK(SearchDefaultOperatorPK searchDefaultOperatorPK) 499 throws PersistenceNotNullException { 500 checkForNull(searchDefaultOperatorPK); 501 502 boolean update = true; 503 504 if(this.searchDefaultOperatorPK != null) { 505 if(this.searchDefaultOperatorPK.equals(searchDefaultOperatorPK)) { 506 update = false; 507 } 508 } else if(searchDefaultOperatorPK == null) { 509 update = false; 510 } 511 512 if(update) { 513 this.searchDefaultOperatorPK = searchDefaultOperatorPK; 514 searchDefaultOperatorPKHasBeenModified = true; 515 clearHashAndString(); 516 } 517 } 518 519 public boolean getSearchDefaultOperatorPKHasBeenModified() { 520 return searchDefaultOperatorPKHasBeenModified; 521 } 522 523 public SearchSortOrderPK getSearchSortOrderPK() { 524 return searchSortOrderPK; 525 } 526 527 public void setSearchSortOrderPK(SearchSortOrderPK searchSortOrderPK) 528 throws PersistenceNotNullException { 529 checkForNull(searchSortOrderPK); 530 531 boolean update = true; 532 533 if(this.searchSortOrderPK != null) { 534 if(this.searchSortOrderPK.equals(searchSortOrderPK)) { 535 update = false; 536 } 537 } else if(searchSortOrderPK == null) { 538 update = false; 539 } 540 541 if(update) { 542 this.searchSortOrderPK = searchSortOrderPK; 543 searchSortOrderPKHasBeenModified = true; 544 clearHashAndString(); 545 } 546 } 547 548 public boolean getSearchSortOrderPKHasBeenModified() { 549 return searchSortOrderPKHasBeenModified; 550 } 551 552 public SearchSortDirectionPK getSearchSortDirectionPK() { 553 return searchSortDirectionPK; 554 } 555 556 public void setSearchSortDirectionPK(SearchSortDirectionPK searchSortDirectionPK) 557 throws PersistenceNotNullException { 558 checkForNull(searchSortDirectionPK); 559 560 boolean update = true; 561 562 if(this.searchSortDirectionPK != null) { 563 if(this.searchSortDirectionPK.equals(searchSortDirectionPK)) { 564 update = false; 565 } 566 } else if(searchSortDirectionPK == null) { 567 update = false; 568 } 569 570 if(update) { 571 this.searchSortDirectionPK = searchSortDirectionPK; 572 searchSortDirectionPKHasBeenModified = true; 573 clearHashAndString(); 574 } 575 } 576 577 public boolean getSearchSortDirectionPKHasBeenModified() { 578 return searchSortDirectionPKHasBeenModified; 579 } 580 581 public Long getFromTime() { 582 return fromTime; 583 } 584 585 public void setFromTime(Long fromTime) 586 throws PersistenceNotNullException { 587 checkForNull(fromTime); 588 589 boolean update = true; 590 591 if(this.fromTime != null) { 592 if(this.fromTime.equals(fromTime)) { 593 update = false; 594 } 595 } else if(fromTime == null) { 596 update = false; 597 } 598 599 if(update) { 600 this.fromTime = fromTime; 601 fromTimeHasBeenModified = true; 602 clearHashAndString(); 603 } 604 } 605 606 public boolean getFromTimeHasBeenModified() { 607 return fromTimeHasBeenModified; 608 } 609 610 public Long getThruTime() { 611 return thruTime; 612 } 613 614 public void setThruTime(Long thruTime) 615 throws PersistenceNotNullException { 616 checkForNull(thruTime); 617 618 boolean update = true; 619 620 if(this.thruTime != null) { 621 if(this.thruTime.equals(thruTime)) { 622 update = false; 623 } 624 } else if(thruTime == null) { 625 update = false; 626 } 627 628 if(update) { 629 this.thruTime = thruTime; 630 thruTimeHasBeenModified = true; 631 clearHashAndString(); 632 } 633 } 634 635 public boolean getThruTimeHasBeenModified() { 636 return thruTimeHasBeenModified; 637 } 638 639}