Class VocabularyUtils

    • Method Detail

      • 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
      • 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