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.apache.commons.lang3.StringUtils; 017 018/** 019 * Enumeration to classify name usages by how they originated. 020 */ 021public enum Origin { 022 023 /** 024 * Record came straight from source record. 025 */ 026 SOURCE, 027 028 /** 029 * Implicit usage from a denormalized classification. 030 */ 031 DENORMED_CLASSIFICATION, 032 033 /** 034 * Implicit usage from a verbatim parent name usage. 035 */ 036 VERBATIM_PARENT, 037 038 /** 039 * Implicit usage from a verbatim accepted name usage. 040 */ 041 VERBATIM_ACCEPTED, 042 043 /** 044 * Implicit usage from a verbatim basionym/original name. 045 */ 046 VERBATIM_BASIONYM, 047 048 /** 049 * Duplicated usage from a single pro parte record. 050 */ 051 PROPARTE, 052 053 /** 054 * Generated, missing autonym. 055 */ 056 AUTONYM, 057 058 /** 059 * Generated, missing genus or species for "orphaned" lower name. 060 */ 061 IMPLICIT_NAME, 062 063 /** 064 * Artificial accepted usage for a synonym if it's missing to preserve the taxonomic hierarchy. 065 */ 066 MISSING_ACCEPTED, 067 068 /** 069 * Placeholder usage for a missing or implicit basionym. 070 */ 071 BASIONYM_PLACEHOLDER, 072 073 /** 074 * Implicit synonym based on the illegitimate ex author. 075 * See ICN article 46: http://www.iapt-taxon.org/nomen/main.php?page=art46 076 */ 077 EX_AUTHOR_SYNONYM, 078 079 /** 080 * Any other origin not covered by the above. 081 */ 082 OTHER; 083 084 /** 085 * Case-insensitive lookup of an Origin by its name that does not throw an exception but returns null 086 * for not found origins. 087 * 088 * @param origin case-insensitive name of the origin 089 * 090 * @return the matching Origin or null 091 */ 092 public static Origin fromString(String origin) { 093 if (StringUtils.isNotEmpty(origin)) { 094 try { 095 return valueOf(origin.toUpperCase().trim()); 096 } catch (IllegalArgumentException e) { 097 // swallow 098 } 099 } 100 return null; 101 } 102 103}