Package org.apache.wicket.util.value
Interface IValueMap
-
- All Known Implementing Classes:
AttributeMap
,CopyOnWriteValueMap
,ValueMap
public interface IValueMap extends Map<String,Object>
AMap
interface that holds values, parsesString
s, and exposes a variety of convenience methods.- Since:
- 1.2.6
- Author:
- Johan Compagner, Doug Donohoe
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Boolean
getAsBoolean(String key)
Retrieves aBoolean
value by key.boolean
getAsBoolean(String key, boolean defaultValue)
Retrieves aboolean
value by key.Double
getAsDouble(String key)
Retrieves aDouble
value by key.double
getAsDouble(String key, double defaultValue)
Retrieves adouble
value by key.Duration
getAsDuration(String key)
Retrieves aDuration
value by key.Duration
getAsDuration(String key, Duration defaultValue)
Retrieves aDuration
value by key.<T extends Enum<T>>
TgetAsEnum(String key, Class<T> eClass)
Retrieves anEnum
value by key.<T extends Enum<T>>
TgetAsEnum(String key, Class<T> eClass, T defaultValue)
Retrieves anEnum
value by key.<T extends Enum<T>>
TgetAsEnum(String key, T defaultValue)
Retrieves anEnum
value by key.Instant
getAsInstant(String key)
Retrieves aTime
value by key.Integer
getAsInteger(String key)
Retrieves anInteger
value by key.int
getAsInteger(String key, int defaultValue)
Retrieves aninteger
value by key.Long
getAsLong(String key)
Retrieves aLong
value by key.long
getAsLong(String key, long defaultValue)
Retrieves along
value by key.Instant
getAsTime(String key, Instant defaultValue)
Retrieves aTime
value by key.boolean
getBoolean(String key)
Retrieves aboolean
value by key.CharSequence
getCharSequence(String key)
Retrieves aCharSequence
by key.double
getDouble(String key)
Retrieves adouble
value by key.double
getDouble(String key, double defaultValue)
Retrieves adouble
value by key, using a default value if not found.Duration
getDuration(String key)
Retrieves aDuration
by key.Instant
getInstant(String key)
Retrieves aInstant
object by key.int
getInt(String key)
Retrieves anint
value by key.int
getInt(String key, int defaultValue)
Retrieves anint
value by key, using a default value if not found.String
getKey(String key)
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
getLong(String key)
Retrieves along
value by key.long
getLong(String key, long defaultValue)
Retrieves along
value by key, using a default value if not found.String
getString(String key)
Retrieves aString
by key.String
getString(String key, String defaultValue)
Retrieves aString
by key, using a default value if not found.String[]
getStringArray(String key)
Retrieves aString
array by key.StringValue
getStringValue(String key)
Retrieves aStringValue
object by key.boolean
isImmutable()
Returns whether or not thisIValueMap
is immutable.IValueMap
makeImmutable()
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 Detail
-
getBoolean
boolean getBoolean(String key) throws StringValueConversionException
Retrieves aboolean
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getDouble
double getDouble(String key) throws StringValueConversionException
Retrieves adouble
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getDouble
double getDouble(String key, double defaultValue) throws StringValueConversionException
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
Duration getDuration(String key) throws StringValueConversionException
Retrieves aDuration
by key.- Parameters:
key
- the key- Returns:
- the
Duration
value - Throws:
StringValueConversionException
-
getInt
int getInt(String key) throws StringValueConversionException
Retrieves anint
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getInt
int getInt(String key, int defaultValue) throws StringValueConversionException
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
long getLong(String key) throws StringValueConversionException
Retrieves along
value by key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
StringValueConversionException
-
getLong
long getLong(String key, long defaultValue) throws StringValueConversionException
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
String getString(String key, String defaultValue)
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
String getString(String key)
Retrieves aString
by key.- Parameters:
key
- the key- Returns:
- the
String
-
getCharSequence
CharSequence getCharSequence(String key)
Retrieves aCharSequence
by key.- Parameters:
key
- the key- Returns:
- the
CharSequence
-
getStringArray
String[] getStringArray(String key)
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
StringValue getStringValue(String key)
Retrieves aStringValue
object by key.- Parameters:
key
- the key- Returns:
- the
StringValue
object
-
getInstant
Instant getInstant(String key) throws StringValueConversionException
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
IValueMap 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
String getKey(String key)
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
Boolean getAsBoolean(String key)
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
boolean getAsBoolean(String key, boolean defaultValue)
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
Integer getAsInteger(String key)
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
int getAsInteger(String key, int defaultValue)
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
Long getAsLong(String key)
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
long getAsLong(String key, long defaultValue)
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
Double getAsDouble(String key)
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
double getAsDouble(String key, double defaultValue)
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
Duration getAsDuration(String key)
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
Duration getAsDuration(String key, Duration defaultValue)
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
Instant getAsInstant(String key)
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
Instant getAsTime(String key, Instant defaultValue)
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
<T extends Enum<T>> T getAsEnum(String key, Class<T> eClass)
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
<T extends Enum<T>> T getAsEnum(String key, T defaultValue)
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
<T extends Enum<T>> T getAsEnum(String key, Class<T> eClass, T defaultValue)
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
-
-