001/*
002 * Copyright 2013 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.vocabulary;
017
018import org.gbif.api.util.VocabularyUtils;
019
020/**
021 * Enumeration for all continents based on the 7 number model found on
022 * <a href="http://en.wikipedia.org/wiki/Continent#Number_of_continents">Wikipedia</a>.
023 *
024 * In particular this splits the Americas into North and South America with North America including the Caribbean and
025 * reaching down and including Panama. See the <a href="http://upload.wikimedia.org/wikipedia/commons/1/19/Continents_vide_couleurs.png">Wikipedia continent map</a> for the exact divisions.
026 */
027public enum Continent {
028
029  AFRICA("Africa"),
030  ANTARCTICA("Antarctica"),
031  ASIA("Asia"),
032  OCEANIA("Oceania"),
033  EUROPE("Europe"),
034  /**
035   * North America includes the Caribbean and
036   * reachies down and includes Panama.
037   */
038  NORTH_AMERICA("North America"),
039  SOUTH_AMERICA("South America");
040
041  private final String title;
042
043  Continent(String title) {
044    this.title = title;
045  }
046
047  /**
048   * @return the continent name in the English language.
049   */
050  public String getTitle() {
051    return title;
052  }
053
054  /**
055   * @param continent name
056   *
057   * @return the matching continent or null
058   */
059  public static Continent fromString(String continent) {
060    try {
061      return (Continent) VocabularyUtils.lookupEnum(continent, Continent.class);
062    } catch (IllegalArgumentException e) {
063      return null;
064    }
065  }
066}