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.vocabulary;
015
016import org.gbif.api.util.VocabularyUtils;
017
018import io.swagger.v3.oas.annotations.ExternalDocumentation;
019import io.swagger.v3.oas.annotations.media.Schema;
020
021/**
022 * <p>Enumeration for all continents based on the 7 continent model found on
023 * <a href="https://en.wikipedia.org/wiki/Continent#Number_of_continents">Wikipedia</a> and the
024 * <a href="http://www.tdwg.org/standards/109">World Geographical Scheme for Recording Plant Distributions (WGSRPD)</a>.
025 *
026 * <p>In particular this splits the Americas into North and South America with North America including the Caribbean (except Trinidad and Tobago) and
027 * reaching down and including Panama. See the <a href="https://github.com/gbif/continents/">GBIF Continents</a> for the exact divisions.
028 *
029 * <p>This is a geographical division.  For GBIF's political divisions, see {@link GbifRegion}.
030 */
031@Schema(
032  description = "The continent, based on a 7 continent model described on [Wikipedia](https://en.wikipedia.org/wiki/Continent#Number_of_continents) " +
033    "and the [World Geographical Scheme for Recording Plant Distributions (WGSRPD)](https://www.tdwg.org/standards/109).\n\n" +
034    "In particular this splits the Americas into North and South America with North America including the Caribbean " +
035    "(except Trinidad and Tobago) and reaching down and including Panama.\n\n" +
036    "See the [GBIF Continents](https://github.com/gbif/continents/) for the exact divisions.\n\n" +
037    "*This is a geographical division.  See `GBIFRegion` for GBIF's political divisions.*",
038  externalDocs = @ExternalDocumentation(
039    description = "API call to retrieve all official values.",
040    url = "https://api.gbif.org/v1/enumeration/basic/Continent"
041  )
042)
043public enum Continent {
044
045  /**
046   * Africa.
047   */
048  AFRICA("Africa"),
049
050  /**
051   * Antarctica.
052   */
053  ANTARCTICA("Antarctica"),
054
055  /**
056   * Asia.
057   */
058  ASIA("Asia"),
059
060  /**
061   * Oceania.
062   */
063  OCEANIA("Oceania"),
064
065  /**
066   * Europe.
067   */
068  EUROPE("Europe"),
069
070  /**
071   * North America
072   *
073   * <p>This includes the Caribbean and Central America.
074   */
075  NORTH_AMERICA("North America"),
076
077  /**
078   * South America.
079   */
080  SOUTH_AMERICA("South America");
081
082  private final String title;
083
084  Continent(String title) {
085    this.title = title;
086  }
087
088  /**
089   * @return the continent name in the English language.
090   */
091  public String getTitle() {
092    return title;
093  }
094
095  /**
096   * @param continent name
097   *
098   * @return the matching continent or null
099   */
100  public static Continent fromString(String continent) {
101    try {
102      return (Continent) VocabularyUtils.lookupEnum(continent, Continent.class);
103    } catch (IllegalArgumentException e) {
104      return null;
105    }
106  }
107}