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 018/** 019 * A simple enumeration of all kingdoms found in the GBIF Backbone Taxonomy. 020 * 021 * The Catalogue of Life has many more kingdoms these days and data keeps changing, 022 * thus this enumeration is deprecated. 023 */ 024@Deprecated 025public enum Kingdom { 026 027 INCERTAE_SEDIS, 028 ANIMALIA, 029 ARCHAEA, 030 BACTERIA, 031 CHROMISTA, 032 FUNGI, 033 PLANTAE, 034 PROTOZOA, 035 VIRUSES; 036 037 /** 038 * Looks up a kingdom by its nub usage key. 039 * 040 * @param usageKey the nub usage key to lookup, must be < 9 to get a result. 041 * 042 * @return the matching kingdom or null 043 */ 044 public static Kingdom byNubUsageKey(int usageKey) { 045 try { 046 return Kingdom.values()[usageKey]; 047 } catch (IndexOutOfBoundsException e) { 048 throw new IllegalArgumentException("There is no kingdom with usage key " + usageKey); 049 } 050 } 051 052 /** 053 * @return a unique single capital char representing the kingdom. 054 */ 055 public String scientificName() { 056 String lower = name().replaceAll("_", " ").toLowerCase(); 057 return this==INCERTAE_SEDIS ? lower : Character.toUpperCase(lower.charAt(0)) + lower.substring(1); 058 } 059 060 public String nubUsageKey() { 061 return String.valueOf(ordinal()); 062 } 063 064 /** 065 * @deprecated please use nubUsageKey() instead 066 */ 067 @Deprecated 068 public String nubUsageID() { 069 return nubUsageKey(); 070 } 071 072 /** 073 * @deprecated please use byNubUsageId(int) instead 074 */ 075 @Deprecated 076 public static Kingdom byNubUsageId(int usageKey) { 077 return byNubUsageKey(usageKey); 078 } 079}