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 java.io.Serializable;
017
018import com.fasterxml.jackson.annotation.JsonSubTypes;
019import com.fasterxml.jackson.annotation.JsonTypeInfo;
020
021import io.swagger.v3.oas.annotations.media.DiscriminatorMapping;
022import io.swagger.v3.oas.annotations.media.Schema;
023
024@JsonTypeInfo(
025  use = JsonTypeInfo.Id.NAME,
026  property = "type"
027)
028@JsonSubTypes({
029  @JsonSubTypes.Type(value = ConjunctionPredicate.class, name = "and"),
030  @JsonSubTypes.Type(value = DisjunctionPredicate.class, name = "or"),
031  @JsonSubTypes.Type(value = NotPredicate.class, name = "not"),
032  @JsonSubTypes.Type(value = EqualsPredicate.class, name = "equals"),
033  @JsonSubTypes.Type(value = LikePredicate.class, name = "like"),
034  @JsonSubTypes.Type(value = LessThanPredicate.class, name = "lessThan"),
035  @JsonSubTypes.Type(value = LessThanOrEqualsPredicate.class, name = "lessThanOrEquals"),
036  @JsonSubTypes.Type(value = GreaterThanPredicate.class, name = "greaterThan"),
037  @JsonSubTypes.Type(value = GreaterThanOrEqualsPredicate.class, name = "greaterThanOrEquals"),
038  @JsonSubTypes.Type(value = InPredicate.class, name = "in"),
039  @JsonSubTypes.Type(value = RangePredicate.class, name = "range"),
040  @JsonSubTypes.Type(value = WithinPredicate.class, name = "within"),
041  @JsonSubTypes.Type(value = GeoDistancePredicate.class, name = "geoDistance"),
042  @JsonSubTypes.Type(value = IsNullPredicate.class, name = "isNull"),
043  @JsonSubTypes.Type(value = IsNotNullPredicate.class, name = "isNotNull"),
044  @JsonSubTypes.Type(value = FullTextSearchPredicate.class, name = "fullTextSearch")
045})
046@Schema(
047  description = "A predicate defining filters to apply for the download.",
048  discriminatorProperty = "type",
049  discriminatorMapping = {
050    @DiscriminatorMapping(schema = ConjunctionPredicate.class, value = "and"),
051    @DiscriminatorMapping(schema = DisjunctionPredicate.class, value = "or"),
052    @DiscriminatorMapping(schema = NotPredicate.class, value = "not"),
053    @DiscriminatorMapping(schema = EqualsPredicate.class, value = "equals"),
054    @DiscriminatorMapping(schema = LikePredicate.class, value = "like"),
055    @DiscriminatorMapping(schema = LessThanPredicate.class, value = "lessThan"),
056    @DiscriminatorMapping(schema = LessThanOrEqualsPredicate.class, value = "lessThanOrEquals"),
057    @DiscriminatorMapping(schema = GreaterThanPredicate.class, value = "greaterThan"),
058    @DiscriminatorMapping(schema = GreaterThanOrEqualsPredicate.class, value = "greaterThanOrEquals"),
059    @DiscriminatorMapping(schema = InPredicate.class, value = "in"),
060    // Not yet announced for GBIF API use
061    // @DiscriminatorMapping(schema = RangePredicate.class, value = "range"),
062    @DiscriminatorMapping(schema = WithinPredicate.class, value = "within"),
063    @DiscriminatorMapping(schema = GeoDistancePredicate.class, value = "geoDistance"),
064    @DiscriminatorMapping(schema = IsNullPredicate.class, value = "isNull"),
065    @DiscriminatorMapping(schema = IsNotNullPredicate.class, value = "isNotNull")
066    // Not yet ready for use.
067    // @DiscriminatorMapping(schema = FullTextSearchPredicate.class, value = "fullTextSearch")
068  }
069)
070public interface Predicate extends Serializable {
071}