Package ratpack.util
Interface TypeCoercingMap<K>
-
- Type Parameters:
K
- The type of the keys
- All Superinterfaces:
java.util.Map<K,java.lang.String>
- All Known Subinterfaces:
PathTokens
public interface TypeCoercingMap<K> extends java.util.Map<K,java.lang.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 java.lang.Boolean
asBool(K key)
Convert the value with given key to a Boolean, usingBoolean.valueOf(String)
.java.lang.Byte
asByte(K key)
Convert the value with given key to a Byte, usingByte.valueOf(String)
.java.lang.Integer
asInt(K key)
Convert the value with given key to a Integer, usingInteger.valueOf(String)
.java.lang.Long
asLong(K key)
Convert the value with given key to a Long, usingLong.valueOf(String)
.java.lang.Short
asShort(K key)
Convert the value with given key to a Short, usingShort.valueOf(String)
.
-
-
-
Method Detail
-
asBool
java.lang.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
java.lang.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
java.lang.Short asShort(K key) throws java.lang.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:
java.lang.NumberFormatException
- if the value cannot be coerced
-
asInt
java.lang.Integer asInt(K key) throws java.lang.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:
java.lang.NumberFormatException
- if the value cannot be coerced
-
asLong
java.lang.Long asLong(K key) throws java.lang.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:
java.lang.NumberFormatException
- if the value cannot be coerced
-
-