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.checklistbank.search;
015
016import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
017
018import org.gbif.api.model.common.search.SearchParameter;
019import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
020import org.gbif.api.vocabulary.Habitat;
021import org.gbif.api.vocabulary.NameType;
022import org.gbif.api.vocabulary.NameUsageIssue;
023import org.gbif.api.vocabulary.NomenclaturalStatus;
024import org.gbif.api.vocabulary.Origin;
025import org.gbif.api.vocabulary.Rank;
026import org.gbif.api.vocabulary.TaxonomicStatus;
027import org.gbif.api.vocabulary.ThreatStatus;
028
029import java.util.UUID;
030
031/**
032 * Each value in the enum represents a search parameter or facet of the name usage search.
033 */
034@JsonDeserialize(as = NameUsageSearchParameter.class)
035public enum NameUsageSearchParameter implements SearchParameter {
036
037  /**
038   * The checklist dataset key as a UUID.
039   */
040  DATASET_KEY(UUID.class),
041
042  /**
043   * The (sub)dataset constituent key as a UUID. Useful to query larger assembled datasets such as the GBIF Backbone or the Catalogue of Life
044   */
045  CONSTITUENT_KEY(UUID.class),
046
047  /**
048   * Filters by the rank of the name usage.
049   */
050  RANK(Rank.class),
051
052  /**
053   * Filters by any of the higher Linnean rank keys.
054   * Note this is within the respective checklist and not searching NUB keys across all checklists.
055   */
056  HIGHERTAXON_KEY(Integer.class),
057
058  /**
059   * Filter by the taxonomis status.
060   */
061  STATUS(TaxonomicStatus.class),
062
063  /**
064   * Boolean filter for extinct taxa.
065   */
066  IS_EXTINCT(Boolean.class),
067
068  /**
069   * Filter by the known habitats.
070   */
071  HABITAT(Habitat.class),
072
073  /**
074   * Filter by the threat status.
075   */
076  THREAT(ThreatStatus.class),
077
078  /**
079   * Filter by the nomenclatural status.
080   */
081  NOMENCLATURAL_STATUS(NomenclaturalStatus.class),
082
083  /**
084   * Filter by the name type.
085   */
086  NAME_TYPE(NameType.class),
087
088  /**
089   * Searches name usages for those that have a specific issue.
090   */
091  ISSUE(NameUsageIssue.class),
092
093  /**
094   * Searches name usages for those with a specific origin.
095   */
096  ORIGIN(Origin.class);
097
098  private NameUsageSearchParameter(Class<?> type) {
099    this.type = type;
100  }
101
102  private final Class<?> type;
103
104  /**
105   * @return the data type expected for the value of the respective search parameter
106   */
107  @Override
108  public Class<?> type() {
109    return type;
110  }
111}