Class BaseDynaBeanMapDecorator<K>
- Type Parameters:
K- the type of the keys in the decorated map
- Direct Known Subclasses:
DynaBeanMapDecorator, DynaBeanPropertyMapDecorator
A base class for decorators providing Map behavior on
DynaBeans.
The motivation for this implementation is to provide access to DynaBean
properties in technologies that are unaware of BeanUtils and DynaBeans -
such as the expression languages of JSTL and JSF.
This rather technical base class implements the methods of the
Map interface on top of a DynaBean. It was introduced
to handle generic parameters in a meaningful way without breaking
backwards compatibility of the DynaBeanMapDecorator class: A
map wrapping a DynaBean should be of type Map<String, Object>.
However, when using these generic parameters in DynaBeanMapDecorator
this would be an incompatible change (as method signatures would have to
be adapted). To solve this problem, this generic base class is added
which allows specifying the key type as parameter. This makes it easy to
have a new subclass using the correct generic parameters while
DynaBeanMapDecorator could still remain with compatible
parameters.
- Since:
- BeanUtils 1.9.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMap.Entry implementation. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseDynaBeanMapDecorator(DynaBean dynaBean) Constructs a read only Map for the specifiedDynaBean.BaseDynaBeanMapDecorator(DynaBean dynaBean, boolean readOnly) Construct a Map for the specifiedDynaBean. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Always throws UnsupportedOperationException because this operation is unsupported.booleancontainsKey(Object key) Indicate whether theDynaBeancontains a specified value for one (or more) of its properties.booleancontainsValue(Object value) Indicates whether the decoratedDynaBeancontains a specified value.protected abstract KconvertKey(String propertyName) Converts the name of a property to the key type of this decorator.entrySet()Returns the Set of the property/value mappings in the decoratedDynaBean.Return the value for the specified key from the decoratedDynaBean.Provide access to the underlyingDynaBeanthis Map decorates.private DynaProperty[]Convenience method to retrieve theDynaPropertys for thisDynaClass.booleanisEmpty()Indicate whether the decoratedDynaBeanhas any properties.booleanIndicate whether the Map is read only.keySet()Returns the Set of the property names in the decoratedDynaBean.Set the value for the specified property in the decoratedDynaBean.voidCopy the contents of a Map to the decoratedDynaBean.Always throws UnsupportedOperationException because this operation is unsupported.intsize()Returns the number properties in the decoratedDynaBean.private StringConvenience method to convert an Object to a String.values()Returns the set of property values in the decoratedDynaBean.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
dynaBean
-
readOnly
private final boolean readOnly -
keySet
-
-
Constructor Details
-
BaseDynaBeanMapDecorator
Constructs a read only Map for the specifiedDynaBean.- Parameters:
dynaBean- The dyna bean being decorated- Throws:
IllegalArgumentException- if theDynaBeanis null.
-
BaseDynaBeanMapDecorator
Construct a Map for the specifiedDynaBean.- Parameters:
dynaBean- The dyna bean being decoratedreadOnly-trueif the Map is read only otherwisefalse- Throws:
IllegalArgumentException- if theDynaBeanis null.
-
-
Method Details
-
clear
public void clear()Always throws UnsupportedOperationException because this operation is unsupported.- Specified by:
clearin interfaceMap<K,Object> - Throws:
UnsupportedOperationException- Always thrown.
-
containsKey
Indicate whether theDynaBeancontains a specified value for one (or more) of its properties. -
containsValue
-
convertKey
-
entrySet
-
get
-
getDynaBean
-
getDynaProperties
Convenience method to retrieve theDynaPropertys for thisDynaClass.- Returns:
- The an array of the
DynaPropertys.
-
isEmpty
-
isReadOnly
public boolean isReadOnly()Indicate whether the Map is read only.- Returns:
trueif the Map is read only, otherwisefalse.
-
keySet
Returns the Set of the property names in the decorated
DynaBean.N.B.For
DynaBeans whose associatedDynaClassis aMutableDynaClassa new Set is created every time, otherwise the Set is created only once and cached. -
put
Set the value for the specified property in the decoratedDynaBean. -
putAll
-
remove
-
size
-
toString
-
values
-