Package org.wildfly.security.util
Class StringMapping<T>
java.lang.Object
org.wildfly.security.util.StringMapping<T>
An efficient mapping of enumerated strings to some other object.
- Author:
- David M. Lloyd
-
Constructor Summary
ConstructorsConstructorDescriptionStringMapping(StringEnumeration stringEnumeration, Function<String, T> mapping) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptiongetItemById(int index) Get an item from this mapping by ID.getItemByString(String str) Get an item from this mapping by the corresponding string name.Get the string enumeration for this mapping.
-
Constructor Details
-
StringMapping
Construct a new instance.- Parameters:
stringEnumeration- the string enumeration (must not benull)mapping- the mapping function (must not benull)
-
-
Method Details
-
getItemById
Get an item from this mapping by ID.- Parameters:
index- the index to look up- Returns:
- the mapped item for the given ID
- Throws:
IllegalArgumentException- if the given index is out of range
-
getItemByString
Get an item from this mapping by the corresponding string name.- Parameters:
str- the string name- Returns:
- the item
- Throws:
IllegalArgumentException- if the string name is unknown
-
getStringEnumeration
Get the string enumeration for this mapping.- Returns:
- the string enumeration for this mapping (not
null)
-