Package ratpack.func
Interface TypeCoercingMap<K>
-
- Type Parameters:
K
- The type of the keys
- All Known Subinterfaces:
PathTokens
public interface TypeCoercingMap<K> extends Map<K,String>
A string valued map that can do simple type conversions from the string values to primitive types.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Boolean
asBool(K key)
Convert the value with given key to a Boolean, usingBoolean.valueOf(String)
.Byte
asByte(K key)
Convert the value with given key to a Byte, usingByte.valueOf(String)
.Integer
asInt(K key)
Convert the value with given key to a Integer, usingInteger.valueOf(String)
.Long
asLong(K key)
Convert the value with given key to a Long, usingLong.valueOf(String)
.Short
asShort(K key)
Convert the value with given key to a Short, usingShort.valueOf(String)
.-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
asBool
Boolean asBool(K key)
Convert the value with given key to a Boolean, usingBoolean.valueOf(String)
.- Parameters:
key
- The key of the value to convert- Returns:
- The result of
Boolean.valueOf(String)
if the value is not null, else null
-
asByte
Byte asByte(K key)
Convert the value with given key to a Byte, usingByte.valueOf(String)
.- Parameters:
key
- The key of the value to convert- Returns:
- The result of
Byte.valueOf(String)
if the value is not null, else null
-
asShort
Short asShort(K key) throws NumberFormatException
Convert the value with given key to a Short, usingShort.valueOf(String)
.- Parameters:
key
- The key of the value to convert- Returns:
- The result of
Short.valueOf(String)
if the value is not null, else null - Throws:
NumberFormatException
- if the value cannot be coerced
-
asInt
Integer asInt(K key) throws NumberFormatException
Convert the value with given key to a Integer, usingInteger.valueOf(String)
.- Parameters:
key
- The key of the value to convert- Returns:
- The result of
Integer.valueOf(String)
if the value is not null, else null - Throws:
NumberFormatException
- if the value cannot be coerced
-
asLong
Long asLong(K key) throws NumberFormatException
Convert the value with given key to a Long, usingLong.valueOf(String)
.- Parameters:
key
- The key of the value to convert- Returns:
- The result of
Long.valueOf(String)
if the value is not null, else null - Throws:
NumberFormatException
- if the value cannot be coerced
-
-