001/*
002 * Copyright 2020 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.apache.commons.lang3.StringUtils;
019
020/**
021 * A short classification of scientific name strings used in Checklist Bank.
022 *
023 * Deprecated.
024 * Please use the name parser enum instead.
025 * https://github.com/gbif/name-parser/blob/master/name-parser-api/src/main/java/org/gbif/nameparser/api/NameType.java
026 */
027
028@Deprecated
029public enum NameType {
030
031  /**
032   * A scientific latin name that might contain authorship but is not any of the other name types below (virus, hybrid, cultivar, etc).
033   */
034  SCIENTIFIC,
035
036  /**
037   * A virus name.
038   */
039  VIRUS,
040
041  /**
042   * A hybrid <b>formula</b> (not a hybrid name).
043   */
044  HYBRID,
045
046  /**
047   * A scientific name with some informal addition like "cf." or indetermined like Abies spec.
048   */
049  INFORMAL,
050
051  /**
052   * A cultivated plant name.
053   */
054  CULTIVAR,
055
056  /**
057   * Candidatus is a component of the taxonomic name for a bacterium that cannot be maintained in a
058   * Bacteriology Culture Collection. It is an interim taxonomic status for noncultivable organisms.
059   * An example would be "Candidatus Phytoplasma allocasuarinae".
060   * This can be abbreviated to "Ca. Phytoplasma allocasuarinae".
061   *
062   * @see <a href="http://en.wikipedia.org/wiki/Candidatus">wikipedia</a>
063   * @see <a href="http://www.bacterio.cict.fr/candidatus.html">J.P. Euzéby</a>
064   *
065   */
066  CANDIDATUS,
067
068  /**
069   * Operational Taxonomic Unit.
070   * An OTU is a pragmatic definition to group individuals by similarity, equivalent to but not necessarily in line
071   * with classical Linnaean taxonomy or modern Evolutionary taxonomy.
072   *
073   * A OTU usually refers to clusters of organisms, grouped by DNA sequence similarity of a specific taxonomic marker gene.
074   * In other words, OTUs are pragmatic proxies for "species" at different taxonomic levels.
075   *
076   * Sequences can be clustered according to their similarity to one another,
077   * and operational taxonomic units are defined based on the similarity threshold (usually 97% similarity) set by the researcher.
078   * Typically, OTU's are based on similar 16S rRNA sequences.
079   */
080  OTU,
081
082  /**
083   * Doubtful whether this is a scientific name at all.
084   */
085  DOUBTFUL,
086
087  /**
088   * A placeholder name like "incertae sedis" or "unknown genus".
089   */
090  PLACEHOLDER,
091
092  /**
093   * Surely not a scientific name of any kind.
094   */
095  NO_NAME,
096
097  /**
098   * A name that has been flagged by the name parser due to the use of blacklisted epithets/words.
099   */
100  BLACKLISTED;
101
102  /**
103   * Case insensitive lookup of a name type by its name that does not throw an exception but returns null
104   * for not found name types.
105   *
106   * @param nameType case insensitive name of name type
107   *
108   * @return the matching NameType or null
109   */
110  public static NameType fromString(String nameType) {
111    if (StringUtils.isNotEmpty(nameType)) {
112      try {
113        return valueOf(nameType.toUpperCase().trim());
114      } catch (IllegalArgumentException e) {
115        // swallow
116      }
117    }
118    return null;
119  }
120
121  /**
122   * @return true if the type of name is included in the GBIF backbone
123   */
124  public boolean isBackboneType() {
125    return this == SCIENTIFIC || this == VIRUS || this == DOUBTFUL;
126  }
127
128  /**
129   * @return true if the GBIF name parser can parse such a name into a ParsedName instance
130   */
131  public boolean isParsable() {
132    return this == SCIENTIFIC || this == INFORMAL || this == CULTIVAR || this == CANDIDATUS || this == DOUBTFUL || this == BLACKLISTED;
133  }
134
135}