001/*- 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.search.builder.models; 021 022import com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn; 023import org.apache.commons.lang3.builder.EqualsBuilder; 024import org.apache.commons.lang3.builder.HashCodeBuilder; 025 026public class PredicateBuilderCacheKey { 027 private final DbColumn myDbColumn; 028 private final PredicateBuilderTypeEnum myType; 029 private final String myParamName; 030 private final int myHashCode; 031 032 public PredicateBuilderCacheKey(DbColumn theDbColumn, PredicateBuilderTypeEnum theType, String theParamName) { 033 myDbColumn = theDbColumn; 034 myType = theType; 035 myParamName = theParamName; 036 myHashCode = new HashCodeBuilder() 037 .append(myDbColumn) 038 .append(myType) 039 .append(myParamName) 040 .toHashCode(); 041 } 042 043 @Override 044 public boolean equals(Object theO) { 045 if (this == theO) { 046 return true; 047 } 048 049 if (theO == null || getClass() != theO.getClass()) { 050 return false; 051 } 052 053 PredicateBuilderCacheKey that = (PredicateBuilderCacheKey) theO; 054 055 return new EqualsBuilder() 056 .append(myDbColumn, that.myDbColumn) 057 .append(myType, that.myType) 058 .append(myParamName, that.myParamName) 059 .isEquals(); 060 } 061 062 @Override 063 public int hashCode() { 064 return myHashCode; 065 } 066}