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 dynamicBeanbased 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. SeeFlexiBeanfor 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 MapBeanclone()static DynamicMetaBeanmeta()Creates a standalone meta-bean.DynamicMetaBeanmetaBean()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.voidpropertyDefine(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.voidpropertyRemove(String propertyName)Removes a property by name.StringtoString()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:DynamicBeanGets the meta-bean representing the parts of the bean that are common across all instances, such as the set of meta-properties.- Specified by:
metaBeanin interfaceBean- Specified by:
metaBeanin interfaceDynamicBean- Returns:
- the meta-bean, not null
-
property
public Property<Object> property(String name)
Description copied from interface:DynamicBeanGets 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:
propertyin interfaceBean- Specified by:
propertyin interfaceDynamicBean- Parameters:
name- the property name to retrieve, not null- Returns:
- the property, not null
-
propertyNames
public Set<String> propertyNames()
Description copied from interface:BeanGets the set of property names.Each bean consists of a known set of properties. This method returns the known property names.
- Specified by:
propertyNamesin interfaceBean- Returns:
- the unmodifiable set of property names, not null
-
propertyDefine
public void propertyDefine(String propertyName, Class<?> propertyType)
Description copied from interface:DynamicBeanAdds 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:
propertyDefinein 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:DynamicBeanRemoves a property by name.- Specified by:
propertyRemovein 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:
toStringin classAbstractMap<String,Object>- Returns:
- a summary string, not null
-
-