Package org.gbif.api.util
Class VocabularyUtils
- java.lang.Object
-
- org.gbif.api.util.VocabularyUtils
-
public final class VocabularyUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T extends Enum<?>>
Optional<T>lookup(String name, Class<T> vocab)
Same 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.static Class<? extends Enum<?>>
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
parseTechnicalInstallationType(String type)
Deprecated.
-
-
-
Method Detail
-
parseContactType
public static ContactType parseContactType(String type)
-
parseEndpointType
public static EndpointType parseEndpointType(String type)
-
parseIdentifierType
public static IdentifierType parseIdentifierType(String type)
-
parseTechnicalInstallationType
@Deprecated public static TechnicalInstallationType parseTechnicalInstallationType(String type)
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 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
public static <T extends Enum<?>> Optional<T> lookup(String name, Class<T> vocab)
Same aslookupEnum(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
- iffullyQualifiedClassName
class cannot be located
-
-