Package org.joda.beans.impl.map
Class MapBean
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,Object>
-
- org.joda.beans.impl.map.MapBean
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,Object>
,Bean
,DynamicBean
public class MapBean extends HashMap<String,Object> implements DynamicBean
Implementation of a fully dynamicBean
based on an exposedMap
.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. SeeFlexiBean
for a map-like bean implementation that is more controlled.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description MapBean()
Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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<Object>
property(String name)
Gets a property by name.void
propertyDefine(String propertyName, Class<?> propertyType)
Adds a property to those allowed to be stored in the bean.Set<String>
propertyNames()
Gets the set of property names.void
propertyRemove(String propertyName)
Removes a property by name.String
toString()
Returns a string that summarises the bean.-
Methods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
-
-
-
Method Detail
-
meta
public static DynamicMetaBean meta()
Creates a standalone meta-bean.This creates a new instance each time in line with dynamic bean principles.
- Returns:
- the meta-bean, not null
-
metaBean
public DynamicMetaBean metaBean()
Description copied from interface:DynamicBean
Gets the meta-bean representing the parts of the bean that are common across all instances, such as the set of meta-properties.- Specified by:
metaBean
in interfaceBean
- Specified by:
metaBean
in interfaceDynamicBean
- Returns:
- the meta-bean, not null
-
property
public Property<Object> property(String name)
Description copied from interface:DynamicBean
Gets a property by name.This will not throw an exception if the property name does not exist. Whether a property is immediately created or not is implementation dependent.
- Specified by:
property
in interfaceBean
- Specified by:
property
in interfaceDynamicBean
- Parameters:
name
- the property name to retrieve, not null- Returns:
- the property, not null
-
propertyNames
public Set<String> propertyNames()
Description copied from interface:Bean
Gets the set of property names.Each bean consists of a known set of properties. This method returns the known property names.
- Specified by:
propertyNames
in interfaceBean
- Returns:
- the unmodifiable set of property names, not null
-
propertyDefine
public void propertyDefine(String propertyName, Class<?> propertyType)
Description copied from interface:DynamicBean
Adds a property to those allowed to be stored in the bean.Some implementations will automatically add properties, in which case this method will have no effect.
- Specified by:
propertyDefine
in interfaceDynamicBean
- Parameters:
propertyName
- the property name to check, not empty, not nullpropertyType
- the property type, not null
-
propertyRemove
public void propertyRemove(String propertyName)
Description copied from interface:DynamicBean
Removes a property by name.- Specified by:
propertyRemove
in interfaceDynamicBean
- Parameters:
propertyName
- the property name to remove, null ignored
-
toString
public String toString()
Returns a string that summarises the bean.The string contains the class name and properties.
- Overrides:
toString
in classAbstractMap<String,Object>
- Returns:
- a summary string, not null
-
-