- All Known Implementing Classes:
AttributeMap
,CopyOnWriteValueMap
,ValueMap
A
Map
interface that holds values, parses String
s, and exposes a
variety of convenience methods.- Since:
- 1.2.6
- Author:
- Johan Compagner, Doug Donohoe
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetAsBoolean
(String key) Retrieves aBoolean
value by key.boolean
getAsBoolean
(String key, boolean defaultValue) Retrieves aboolean
value by key.getAsDouble
(String key) Retrieves aDouble
value by key.double
getAsDouble
(String key, double defaultValue) Retrieves adouble
value by key.getAsDuration
(String key) Retrieves aDuration
value by key.getAsDuration
(String key, Duration defaultValue) Retrieves aDuration
value by key.<T extends Enum<T>>
TRetrieves anEnum
value by key.<T extends Enum<T>>
TRetrieves anEnum
value by key.<T extends Enum<T>>
TRetrieves anEnum
value by key.getAsInstant
(String key) Retrieves aTime
value by key.getAsInteger
(String key) Retrieves anInteger
value by key.int
getAsInteger
(String key, int defaultValue) Retrieves aninteger
value by key.Retrieves aLong
value by key.long
Retrieves along
value by key.Retrieves aTime
value by key.boolean
getBoolean
(String key) Retrieves aboolean
value by key.getCharSequence
(String key) Retrieves aCharSequence
by key.double
Retrieves adouble
value by key.double
Retrieves adouble
value by key, using a default value if not found.getDuration
(String key) Retrieves aDuration
by key.getInstant
(String key) Retrieves aInstant
object by key.int
Retrieves anint
value by key.int
Retrieves anint
value by key, using a default value if not found.Provided that the hash key is aString
and you need to access the value ignoring the key's case (upper- or lowercase letters), then you may use this method to get the correct writing.long
Retrieves along
value by key.long
Retrieves along
value by key, using a default value if not found.Retrieves aString
by key.Retrieves aString
by key, using a default value if not found.String[]
getStringArray
(String key) Retrieves aString
array by key.getStringValue
(String key) Retrieves aStringValue
object by key.boolean
Returns whether or not thisIValueMap
is immutable.Makes thisIValueMap
immutable by changing the underlying map representation to aCollections.unmodifiableMap
.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 Details
-
getBoolean
Retrieves aboolean
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getDouble
Retrieves adouble
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getDouble
Retrieves adouble
value by key, using a default value if not found.- Parameters:
key
- the keydefaultValue
- value to use if no value is in thisIValueMap
- Returns:
- the value
- Throws:
StringValueConversionException
-
getDuration
Retrieves aDuration
by key.- Parameters:
key
- the key- Returns:
- the
Duration
value - Throws:
StringValueConversionException
-
getInt
Retrieves anint
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getInt
Retrieves anint
value by key, using a default value if not found.- Parameters:
key
- the keydefaultValue
- value to use if no value is in thisIValueMap
- Returns:
- the value
- Throws:
StringValueConversionException
-
getLong
Retrieves along
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getLong
Retrieves along
value by key, using a default value if not found.- Parameters:
key
- the keydefaultValue
- value to use if no value in thisIValueMap
- Returns:
- the value
- Throws:
StringValueConversionException
-
getString
Retrieves aString
by key, using a default value if not found.- Parameters:
key
- the keydefaultValue
- default value to return if value isnull
- Returns:
- the
String
-
getString
Retrieves aString
by key.- Parameters:
key
- the key- Returns:
- the
String
-
getCharSequence
Retrieves aCharSequence
by key.- Parameters:
key
- the key- Returns:
- the
CharSequence
-
getStringArray
Retrieves aString
array by key. If the value was aString[]
it will be returned directly. If it was aString
it will be converted to aString
array of length one. If it was an array of another type, aString
array will be made and each element will be converted to aString
.- Parameters:
key
- the key- Returns:
- the
String
array of that key
-
getStringValue
Retrieves aStringValue
object by key.- Parameters:
key
- the key- Returns:
- the
StringValue
object
-
getInstant
Retrieves aInstant
object by key.- Parameters:
key
- the key- Returns:
- the
Instant
object - Throws:
StringValueConversionException
-
isImmutable
boolean isImmutable()Returns whether or not thisIValueMap
is immutable.- Returns:
- whether or not this
IValueMap
is immutable
-
makeImmutable
Makes thisIValueMap
immutable by changing the underlying map representation to aCollections.unmodifiableMap
. After calling this method, any attempt to modify thisIValueMap
will result in aRuntimeException
being thrown by theCollections
framework.- Returns:
- this
IValueMap
-
getKey
Provided that the hash key is aString
and you need to access the value ignoring the key's case (upper- or lowercase letters), then you may use this method to get the correct writing.- Parameters:
key
- the key- Returns:
- the key with the correct writing
-
getAsBoolean
Retrieves aBoolean
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid boolean or no value is in this
IValueMap
-
getAsBoolean
Retrieves aboolean
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid boolean or no value is in this
IValueMap
-
getAsInteger
Retrieves anInteger
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid integer or no value is in this
IValueMap
-
getAsInteger
Retrieves aninteger
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid integer or no value is in this
IValueMap
-
getAsLong
Retrieves aLong
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid long or no value is in this
IValueMap
-
getAsLong
Retrieves along
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid long or no value is in this
IValueMap
-
getAsDouble
Retrieves aDouble
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid double or no value is in this
IValueMap
-
getAsDouble
Retrieves adouble
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid double or no value is in this
IValueMap
-
getAsDuration
Retrieves aDuration
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid Duration or no value is in this
IValueMap
-
getAsDuration
Retrieves aDuration
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid Duration or no value is in this
IValueMap
-
getAsInstant
Retrieves aTime
value by key.- Parameters:
key
- the key- Returns:
- the value or null if value is not a valid Time or no value is in this
IValueMap
-
getAsTime
Retrieves aTime
value by key.- Parameters:
key
- the keydefaultValue
- the default to return- Returns:
- the value or defaultValue if value is not a valid Time or no value is in this
IValueMap
-
getAsEnum
Retrieves anEnum
value by key.- Type Parameters:
T
- type of enum- Parameters:
key
- the keyeClass
- the enumeration class- Returns:
- the value or null if value is not a valid value of the Enumeration or no value is in
this
IValueMap
-
getAsEnum
Retrieves anEnum
value by key.- Type Parameters:
T
- type of enum- Parameters:
key
- the keydefaultValue
- the default value from the Enumeration (cannot be null)- Returns:
- the value or defaultValue if value is not a valid value of the Enumeration or no
value is in this
IValueMap
-
getAsEnum
Retrieves anEnum
value by key.- Type Parameters:
T
- type of enum- Parameters:
key
- the keyeClass
- the enumeration classdefaultValue
- the default value from the Enumeration (may be null)- Returns:
- the value or defaultValue if value is not a valid value of the Enumeration or no
value is in this
IValueMap
-