Package org.apache.wicket.util.value
Class CopyOnWriteValueMap
- java.lang.Object
-
- org.apache.wicket.util.value.CopyOnWriteValueMap
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Map<java.lang.String,java.lang.Object>,IValueMap
public class CopyOnWriteValueMap extends java.lang.Object implements IValueMap, java.io.Serializable
An implementation ofIValueMapthat makes a copy when a caller tries to change an immutableMap. That is, theMapmay or may not be immutable, but if it is, a copy is made.- Since:
- 1.2.6
- Author:
- Johan Compagner, Doug Donohoe
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CopyOnWriteValueMap(IValueMap wrapped)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()booleanequals(java.lang.Object o)java.lang.Objectget(java.lang.Object key)java.lang.BooleangetAsBoolean(java.lang.String key)Retrieves aBooleanvalue by key.booleangetAsBoolean(java.lang.String key, boolean defaultValue)Retrieves abooleanvalue by key.java.lang.DoublegetAsDouble(java.lang.String key)Retrieves aDoublevalue by key.doublegetAsDouble(java.lang.String key, double defaultValue)Retrieves adoublevalue by key.DurationgetAsDuration(java.lang.String key)Retrieves aDurationvalue by key.DurationgetAsDuration(java.lang.String key, Duration defaultValue)Retrieves aDurationvalue by key.<T extends java.lang.Enum<T>>
TgetAsEnum(java.lang.String key, java.lang.Class<T> eClass)Retrieves anEnumvalue by key.<T extends java.lang.Enum<T>>
TgetAsEnum(java.lang.String key, java.lang.Class<T> eClass, T defaultValue)Retrieves anEnumvalue by key.<T extends java.lang.Enum<T>>
TgetAsEnum(java.lang.String key, T defaultValue)Retrieves anEnumvalue by key.java.lang.IntegergetAsInteger(java.lang.String key)Retrieves anIntegervalue by key.intgetAsInteger(java.lang.String key, int defaultValue)Retrieves anintegervalue by key.java.lang.LonggetAsLong(java.lang.String key)Retrieves aLongvalue by key.longgetAsLong(java.lang.String key, long defaultValue)Retrieves alongvalue by key.TimegetAsTime(java.lang.String key)Retrieves aTimevalue by key.TimegetAsTime(java.lang.String key, Time defaultValue)Retrieves aTimevalue by key.booleangetBoolean(java.lang.String key)Retrieves abooleanvalue by key.java.lang.CharSequencegetCharSequence(java.lang.String key)Retrieves aCharSequenceby key.doublegetDouble(java.lang.String key)Retrieves adoublevalue by key.doublegetDouble(java.lang.String key, double defaultValue)Retrieves adoublevalue by key, using a default value if not found.DurationgetDuration(java.lang.String key)Retrieves aDurationby key.intgetInt(java.lang.String key)Retrieves anintvalue by key.intgetInt(java.lang.String key, int defaultValue)Retrieves anintvalue by key, using a default value if not found.java.lang.StringgetKey(java.lang.String key)Provided that the hash key is aStringand 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.longgetLong(java.lang.String key)Retrieves alongvalue by key.longgetLong(java.lang.String key, long defaultValue)Retrieves alongvalue by key, using a default value if not found.java.lang.StringgetString(java.lang.String key)Retrieves aStringby key.java.lang.StringgetString(java.lang.String key, java.lang.String defaultValue)Retrieves aStringby key, using a default value if not found.java.lang.String[]getStringArray(java.lang.String key)Retrieves aStringarray by key.StringValuegetStringValue(java.lang.String key)Retrieves aStringValueobject by key.TimegetTime(java.lang.String key)Retrieves aTimeobject by key.inthashCode()booleanisEmpty()booleanisImmutable()Returns whether or not thisIValueMapis immutable.java.util.Set<java.lang.String>keySet()IValueMapmakeImmutable()Makes thisIValueMapimmutable by changing the underlying map representation to aCollections.unmodifiableMap.java.lang.Objectput(java.lang.String key, java.lang.Object value)voidputAll(java.util.Map<? extends java.lang.String,?> map)java.lang.Objectremove(java.lang.Object key)intsize()java.util.Collection<java.lang.Object>values()
-
-
-
Constructor Detail
-
CopyOnWriteValueMap
public CopyOnWriteValueMap(IValueMap wrapped)
Constructor.- Parameters:
wrapped- the wrappedIValueMap
-
-
Method Detail
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.clear()
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.containsKey(Object)
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.containsValue(Object)
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.entrySet()
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
equalsin classjava.lang.Object- See Also:
Map.equals(Object)
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
hashCodein classjava.lang.Object
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.get(Object)
-
getBoolean
public boolean getBoolean(java.lang.String key) throws StringValueConversionExceptionDescription copied from interface:IValueMapRetrieves abooleanvalue by key.- Specified by:
getBooleanin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value
- Throws:
StringValueConversionException- See Also:
IValueMap.getBoolean(String)
-
getCharSequence
public java.lang.CharSequence getCharSequence(java.lang.String key)
Description copied from interface:IValueMapRetrieves aCharSequenceby key.- Specified by:
getCharSequencein interfaceIValueMap- Parameters:
key- the key- Returns:
- the
CharSequence - See Also:
IValueMap.getCharSequence(String)
-
getDouble
public double getDouble(java.lang.String key) throws StringValueConversionExceptionDescription copied from interface:IValueMapRetrieves adoublevalue by key.- Specified by:
getDoublein interfaceIValueMap- Parameters:
key- the key- Returns:
- the value
- Throws:
StringValueConversionException- See Also:
IValueMap.getDouble(String)
-
getDouble
public double getDouble(java.lang.String key, double defaultValue)Description copied from interface:IValueMapRetrieves adoublevalue by key, using a default value if not found.- Specified by:
getDoublein interfaceIValueMap- Parameters:
key- the keydefaultValue- value to use if no value is in thisIValueMap- Returns:
- the value
- See Also:
IValueMap.getDouble(String, double)
-
getDuration
public Duration getDuration(java.lang.String key) throws StringValueConversionException
Description copied from interface:IValueMapRetrieves aDurationby key.- Specified by:
getDurationin interfaceIValueMap- Parameters:
key- the key- Returns:
- the
Durationvalue - Throws:
StringValueConversionException- See Also:
IValueMap.getDuration(String)
-
getInt
public int getInt(java.lang.String key, int defaultValue)Description copied from interface:IValueMapRetrieves anintvalue by key, using a default value if not found.- Specified by:
getIntin interfaceIValueMap- Parameters:
key- the keydefaultValue- value to use if no value is in thisIValueMap- Returns:
- the value
- See Also:
IValueMap.getInt(String, int)
-
getInt
public int getInt(java.lang.String key) throws StringValueConversionExceptionDescription copied from interface:IValueMapRetrieves anintvalue by key.- Specified by:
getIntin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value
- Throws:
StringValueConversionException- See Also:
IValueMap.getInt(String)
-
getKey
public java.lang.String getKey(java.lang.String key)
Description copied from interface:IValueMapProvided that the hash key is aStringand 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.- Specified by:
getKeyin interfaceIValueMap- Parameters:
key- the key- Returns:
- the key with the correct writing
- See Also:
IValueMap.getKey(String)
-
getLong
public long getLong(java.lang.String key, long defaultValue)Description copied from interface:IValueMapRetrieves alongvalue by key, using a default value if not found.- Specified by:
getLongin interfaceIValueMap- Parameters:
key- the keydefaultValue- value to use if no value in thisIValueMap- Returns:
- the value
- See Also:
IValueMap.getLong(String, long)
-
getLong
public long getLong(java.lang.String key) throws StringValueConversionExceptionDescription copied from interface:IValueMapRetrieves alongvalue by key.- Specified by:
getLongin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value
- Throws:
StringValueConversionException- See Also:
IValueMap.getLong(String)
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)Description copied from interface:IValueMapRetrieves aStringby key, using a default value if not found.- Specified by:
getStringin interfaceIValueMap- Parameters:
key- the keydefaultValue- default value to return if value isnull- Returns:
- the
String - See Also:
IValueMap.getString(String, String)
-
getString
public java.lang.String getString(java.lang.String key)
Description copied from interface:IValueMapRetrieves aStringby key.- Specified by:
getStringin interfaceIValueMap- Parameters:
key- the key- Returns:
- the
String - See Also:
IValueMap.getString(String)
-
getStringArray
public java.lang.String[] getStringArray(java.lang.String key)
Description copied from interface:IValueMapRetrieves aStringarray by key. If the value was aString[]it will be returned directly. If it was aStringit will be converted to aStringarray of length one. If it was an array of another type, aStringarray will be made and each element will be converted to aString.- Specified by:
getStringArrayin interfaceIValueMap- Parameters:
key- the key- Returns:
- the
Stringarray of that key - See Also:
IValueMap.getStringArray(String)
-
getStringValue
public StringValue getStringValue(java.lang.String key)
Description copied from interface:IValueMapRetrieves aStringValueobject by key.- Specified by:
getStringValuein interfaceIValueMap- Parameters:
key- the key- Returns:
- the
StringValueobject - See Also:
IValueMap.getStringValue(String)
-
getTime
public Time getTime(java.lang.String key) throws StringValueConversionException
Description copied from interface:IValueMapRetrieves aTimeobject by key.- Specified by:
getTimein interfaceIValueMap- Parameters:
key- the key- Returns:
- the
Timeobject - Throws:
StringValueConversionException- See Also:
IValueMap.getTime(String)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.isEmpty()
-
isImmutable
public boolean isImmutable()
Description copied from interface:IValueMapReturns whether or not thisIValueMapis immutable.- Specified by:
isImmutablein interfaceIValueMap- Returns:
- whether or not this
IValueMapis immutable - See Also:
IValueMap.isImmutable()
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.keySet()
-
makeImmutable
public IValueMap makeImmutable()
Description copied from interface:IValueMapMakes thisIValueMapimmutable by changing the underlying map representation to aCollections.unmodifiableMap. After calling this method, any attempt to modify thisIValueMapwill result in aRuntimeExceptionbeing thrown by theCollectionsframework.- Specified by:
makeImmutablein interfaceIValueMap- Returns:
- this
IValueMap - See Also:
IValueMap.makeImmutable()
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.put(Object, Object)
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,?> map)
- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.putAll(Map)
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.remove(Object)
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.size()
-
values
public java.util.Collection<java.lang.Object> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.String,java.lang.Object>- See Also:
Map.values()
-
getAsBoolean
public java.lang.Boolean getAsBoolean(java.lang.String key)
Description copied from interface:IValueMapRetrieves aBooleanvalue by key.- Specified by:
getAsBooleanin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid boolean or no value is in this
IValueMap - See Also:
IValueMap.getAsBoolean(String)
-
getAsBoolean
public boolean getAsBoolean(java.lang.String key, boolean defaultValue)Description copied from interface:IValueMapRetrieves abooleanvalue by key.- Specified by:
getAsBooleanin interfaceIValueMap- 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 - See Also:
IValueMap.getAsBoolean(String, boolean)
-
getAsInteger
public java.lang.Integer getAsInteger(java.lang.String key)
Description copied from interface:IValueMapRetrieves anIntegervalue by key.- Specified by:
getAsIntegerin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid integer or no value is in this
IValueMap - See Also:
IValueMap.getAsInteger(String)
-
getAsInteger
public int getAsInteger(java.lang.String key, int defaultValue)Description copied from interface:IValueMapRetrieves anintegervalue by key.- Specified by:
getAsIntegerin interfaceIValueMap- 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 - See Also:
IValueMap.getAsInteger(String, int)
-
getAsLong
public java.lang.Long getAsLong(java.lang.String key)
Description copied from interface:IValueMapRetrieves aLongvalue by key.- Specified by:
getAsLongin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid long or no value is in this
IValueMap - See Also:
IValueMap.getAsLong(String)
-
getAsLong
public long getAsLong(java.lang.String key, long defaultValue)Description copied from interface:IValueMapRetrieves alongvalue by key.- Specified by:
getAsLongin interfaceIValueMap- 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 - See Also:
IValueMap.getAsLong(String, long)
-
getAsDouble
public java.lang.Double getAsDouble(java.lang.String key)
Description copied from interface:IValueMapRetrieves aDoublevalue by key.- Specified by:
getAsDoublein interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid double or no value is in this
IValueMap - See Also:
IValueMap.getAsDouble(String)
-
getAsDouble
public double getAsDouble(java.lang.String key, double defaultValue)Description copied from interface:IValueMapRetrieves adoublevalue by key.- Specified by:
getAsDoublein interfaceIValueMap- 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 - See Also:
IValueMap.getAsDouble(String, double)
-
getAsDuration
public Duration getAsDuration(java.lang.String key)
Description copied from interface:IValueMapRetrieves aDurationvalue by key.- Specified by:
getAsDurationin interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid Duration or no value is in this
IValueMap - See Also:
IValueMap.getAsDuration(String)
-
getAsDuration
public Duration getAsDuration(java.lang.String key, Duration defaultValue)
Description copied from interface:IValueMapRetrieves aDurationvalue by key.- Specified by:
getAsDurationin interfaceIValueMap- 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 - See Also:
IValueMap.getAsDuration(String, Duration)
-
getAsTime
public Time getAsTime(java.lang.String key)
Description copied from interface:IValueMapRetrieves aTimevalue by key.- Specified by:
getAsTimein interfaceIValueMap- Parameters:
key- the key- Returns:
- the value or null if value is not a valid Time or no value is in this
IValueMap - See Also:
IValueMap.getAsTime(String)
-
getAsTime
public Time getAsTime(java.lang.String key, Time defaultValue)
Description copied from interface:IValueMapRetrieves aTimevalue by key.- Specified by:
getAsTimein interfaceIValueMap- 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 - See Also:
IValueMap.getAsTime(String, Time)
-
getAsEnum
public <T extends java.lang.Enum<T>> T getAsEnum(java.lang.String key, java.lang.Class<T> eClass)Description copied from interface:IValueMapRetrieves anEnumvalue by key.- Specified by:
getAsEnumin interfaceIValueMap- 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 - See Also:
IValueMap.getAsEnum(String, Class)
-
getAsEnum
public <T extends java.lang.Enum<T>> T getAsEnum(java.lang.String key, T defaultValue)Description copied from interface:IValueMapRetrieves anEnumvalue by key.- Specified by:
getAsEnumin interfaceIValueMap- 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 - See Also:
IValueMap.getAsEnum(java.lang.String, java.lang.Class<T>)
-
getAsEnum
public <T extends java.lang.Enum<T>> T getAsEnum(java.lang.String key, java.lang.Class<T> eClass, T defaultValue)Description copied from interface:IValueMapRetrieves anEnumvalue by key.- Specified by:
getAsEnumin interfaceIValueMap- 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 - See Also:
IValueMap.getAsEnum(String, Class, Enum)
-
-