001package ca.uhn.fhir.jpa.api.model;
002
003/*-
004 * #%L
005 * HAPI FHIR JPA API
006 * %%
007 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import org.apache.commons.lang3.builder.EqualsBuilder;
024import org.apache.commons.lang3.builder.HashCodeBuilder;
025
026/**
027 * Denotes a search that should be performed in the background
028 * periodically in order to keep a fresh copy in the query cache.
029 * This improves performance for searches by keeping a copy
030 * loaded in the background.
031 */
032public class WarmCacheEntry {
033
034        private long myPeriodMillis;
035        private String myUrl;
036
037        @Override
038        public boolean equals(Object theO) {
039                if (this == theO) {
040                        return true;
041                }
042
043                if (theO == null || getClass() != theO.getClass()) {
044                        return false;
045                }
046
047                WarmCacheEntry that = (WarmCacheEntry) theO;
048
049                return new EqualsBuilder()
050                        .append(myPeriodMillis, that.myPeriodMillis)
051                        .append(myUrl, that.myUrl)
052                        .isEquals();
053        }
054
055        @Override
056        public int hashCode() {
057                return new HashCodeBuilder(17, 37)
058                        .append(myPeriodMillis)
059                        .append(myUrl)
060                        .toHashCode();
061        }
062
063        public long getPeriodMillis() {
064                return myPeriodMillis;
065        }
066
067        public WarmCacheEntry setPeriodMillis(long thePeriodMillis) {
068                myPeriodMillis = thePeriodMillis;
069                return this;
070        }
071
072        public String getUrl() {
073                return myUrl;
074        }
075
076        public WarmCacheEntry setUrl(String theUrl) {
077                myUrl = theUrl;
078                return this;
079        }
080
081}