org.joda.beans.impl.map
Class MapBean

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by 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 dynamic Bean based on an exposed Map.

Properties are dynamic, and can be added and removed at will from the map.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
MapBean()
          Creates an instance.
 
Method Summary
 MapBean clone()
          Clones this bean, returning an independent copy.
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, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MapBean

public MapBean()
Creates an instance.

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 interface Bean
Specified by:
metaBean in interface DynamicBean
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 interface Bean
Specified by:
property in interface DynamicBean
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.

Specified by:
propertyNames in interface Bean
Returns:
the unmodifiable map of property objects, 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 interface DynamicBean
Parameters:
propertyName - the property name to check, not empty, not null
propertyType - 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 interface DynamicBean
Parameters:
propertyName - the property name to remove, null ignored

clone

public MapBean clone()
Description copied from interface: Bean
Clones this bean, returning an independent copy.

Implementations should covariantly return their own type.

Specified by:
clone in interface Bean
Overrides:
clone in class HashMap<String,Object>
Returns:
the clone, not null

toString

public String toString()
Returns a string that summarises the bean.

The string contains the class name and properties.

Overrides:
toString in class AbstractMap<String,Object>
Returns:
a summary string, not null


Copyright © 2007–2014 Joda.org. All rights reserved.