001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 * http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing, software
008 * distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and
011 * limitations under the License.
012 */
013package org.gbif.api.model.occurrence.predicate;
014
015import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
016
017import com.google.common.base.Objects;
018import org.codehaus.jackson.annotate.JsonCreator;
019import org.codehaus.jackson.annotate.JsonProperty;
020
021/**
022 * This predicate checks if its {@code key} is greater than or equal its {@code value}.
023 */
024public class GreaterThanOrEqualsPredicate extends SimplePredicate {
025
026  @JsonCreator
027  public GreaterThanOrEqualsPredicate(@JsonProperty("key") OccurrenceSearchParameter key,
028    @JsonProperty("value") String value) {
029    super(true, key, value);
030  }
031
032  @Override
033  public boolean equals(Object obj) {
034    if (this == obj) {
035      return true;
036    }
037
038    if (!(obj instanceof GreaterThanOrEqualsPredicate)) {
039      return false;
040    }
041
042    SimplePredicate that = (SimplePredicate) obj;
043    return Objects.equal(this.getKey(), that.getKey()) && Objects.equal(this.getValue(), that.getValue());
044  }
045
046}