java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>, Bean, DynamicBeanpublic class MapBean extends java.util.HashMap<java.lang.String,java.lang.Object> implements DynamicBean
Bean based on an exposed Map.
Properties are dynamic, and can be added and removed at will from the map.
This class extends HashMap, allowing it to be used wherever a map is.
See FlexiBean for a map-like bean implementation that is more controlled.
| Constructor | Description |
|---|---|
MapBean() |
Creates an instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
MapBean |
clone() |
|
static DynamicMetaBean |
meta() |
Creates a standalone meta-bean.
|
DynamicMetaBean |
metaBean() |
Gets the meta-bean representing the parts of the bean that are
common across all instances, such as the set of meta-properties.
|
Property<java.lang.Object> |
property(java.lang.String name) |
Gets a property by name.
|
void |
propertyDefine(java.lang.String propertyName,
java.lang.Class<?> propertyType) |
Adds a property to those allowed to be stored in the bean.
|
java.util.Set<java.lang.String> |
propertyNames() |
Gets the set of property names.
|
void |
propertyRemove(java.lang.String propertyName) |
Removes a property by name.
|
java.lang.String |
toString() |
Returns a string that summarises the bean.
|
public static DynamicMetaBean meta()
This creates a new instance each time in line with dynamic bean principles.
public DynamicMetaBean metaBean()
DynamicBeanmetaBean in interface BeanmetaBean in interface DynamicBeanpublic Property<java.lang.Object> property(java.lang.String name)
DynamicBeanThis will not throw an exception if the property name does not exist. Whether a property is immediately created or not is implementation dependent.
property in interface Beanproperty in interface DynamicBeanname - the property name to retrieve, not nullpublic java.util.Set<java.lang.String> propertyNames()
BeanEach bean consists of a known set of properties. This method returns the known property names.
propertyNames in interface Beanpublic void propertyDefine(java.lang.String propertyName,
java.lang.Class<?> propertyType)
DynamicBeanSome implementations will automatically add properties, in which case this method will have no effect.
propertyDefine in interface DynamicBeanpropertyName - the property name to check, not empty, not nullpropertyType - the property type, not nullpublic void propertyRemove(java.lang.String propertyName)
DynamicBeanpropertyRemove in interface DynamicBeanpropertyName - the property name to remove, null ignoredpublic MapBean clone()
clone in class java.util.HashMap<java.lang.String,java.lang.Object>public java.lang.String toString()
The string contains the class name and properties.
toString in class java.util.AbstractMap<java.lang.String,java.lang.Object>Copyright © 2007–2018 Joda.org. All rights reserved.