Package org.gbif.api.util
Class VocabularyUtils
java.lang.Object
org.gbif.api.util.VocabularyUtils
-
Method Summary
Modifier and TypeMethodDescriptionSame aslookupEnum(String, Class)
} without IllegalArgumentException.static <T extends Enum<?>>
TlookupEnum
(String name, Class<T> vocab) Generic method to lookup an enumeration value for a given string based on the name of the enum member.lookupVocabulary
(String fullyQualifiedClassName) Looks up an enumeration by class name.static ContactType
parseContactType
(String type) static EndpointType
parseEndpointType
(String type) static IdentifierType
parseIdentifierType
(String type) static TechnicalInstallationType
Deprecated.
-
Method Details
-
parseContactType
-
parseEndpointType
-
parseIdentifierType
-
parseTechnicalInstallationType
Deprecated. -
lookupEnum
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 lookupvocab
- 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
Same aslookupEnum(String, Class)
} without IllegalArgumentException. On failure, this method will return Optional.empty().- Returns:
- instance of Optional, never null.
-
lookupVocabulary
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
- iffullyQualifiedClassName
class cannot be located
-