001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014package org.gbif.api.model.predicate; 015 016import org.gbif.api.model.common.search.SearchParameter; 017 018import java.util.Objects; 019 020import javax.annotation.Nullable; 021 022import com.fasterxml.jackson.annotation.JsonCreator; 023import com.fasterxml.jackson.annotation.JsonProperty; 024 025import io.swagger.v3.oas.annotations.media.Schema; 026 027/** 028 * This predicate checks if its {@code key} is equal to its {@code value}. 029 */ 030@Schema( 031 description = "This predicate checks if its `key` is equal to its `value`." 032) 033public class EqualsPredicate<S extends SearchParameter> extends SimplePredicate<S> { 034 @JsonCreator 035 public EqualsPredicate( 036 @JsonProperty("key") S key, 037 @JsonProperty("value") String value, 038 @Nullable @JsonProperty(value = "matchCase") Boolean matchCase) { 039 super(false, key, value, matchCase); 040 } 041 042 @Override 043 public boolean equals(Object obj) { 044 if (this == obj) { 045 return true; 046 } 047 048 if (!(obj instanceof EqualsPredicate)) { 049 return false; 050 } 051 052 SimplePredicate<S> that = (SimplePredicate<S>) obj; 053 return Objects.equals(this.getKey(), that.getKey()) 054 && Objects.equals(this.getValue(), that.getValue()); 055 } 056 057}