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