Class VocabularyUtils

java.lang.Object
org.gbif.api.util.VocabularyUtils

public final class VocabularyUtils extends Object
  • Method Details

    • parseContactType

      public static ContactType parseContactType(String type)
    • parseEndpointType

      public static EndpointType parseEndpointType(String type)
    • parseIdentifierType

    • parseTechnicalInstallationType

      Deprecated.
    • lookupEnum

      public static <T extends Enum<?>> T lookupEnum(String name, Class<T> vocab)
      Generic method to lookup an enumeration value for a given string based on the name of the enum member. The lookup is case insensitive and ignore whitespaces, underscores and dashes.
      Parameters:
      name - the enum members name to lookup
      vocab - the enumeration class
      Returns:
      the matching enum member or null if name is null or empty (see http://dev.gbif.org/issues/browse/POR-2858)
      Throws:
      IllegalArgumentException - if the name cannot be parsed into a known name
    • lookup

      public static <T extends Enum<?>> Optional<T> lookup(String name, Class<T> vocab)
      Same as lookupEnum(String, Class) } without IllegalArgumentException. On failure, this method will return Optional.empty().
      Returns:
      instance of Optional, never null.
    • lookupVocabulary

      public static Class<? extends Enum<?>> lookupVocabulary(String fullyQualifiedClassName)
      Looks up an enumeration by class name. One can get the classname using the likes of:

       
       Country.class.getName()
       
       
      Parameters:
      fullyQualifiedClassName - Which should name the enumeration (e.g. org.gbif.api.vocabulary.Country)
      Returns:
      The enumeration or null if fullyQualifiedClassName is null or empty (see http://dev.gbif.org/issues/browse/POR-2858)
      Throws:
      IllegalArgumentException - if fullyQualifiedClassName class cannot be located