org.joda.beans.impl.reflection
Class ReflectiveMetaBean

java.lang.Object
  extended by org.joda.beans.impl.reflection.ReflectiveMetaBean
All Implemented Interfaces:
MetaBean

public final class ReflectiveMetaBean
extends Object
implements MetaBean

A standard meta-bean implementation.

This is the standard implementation of a meta-bean. It requires that the bean implements Bean and has a no-arguments constructor.


Method Summary
 String beanName()
          Gets the bean name, which is normally the fully qualified class name of the bean.
 Class<? extends Bean> beanType()
          Get the type of the bean represented as a Class.
 BeanBuilder<Bean> builder()
          Creates a bean builder that can be used to create an instance of this bean.
 PropertyMap createPropertyMap(Bean bean)
          Creates a map of properties for the specified bean.
 boolean equals(Object obj)
           
 int hashCode()
           
<R> MetaProperty<R>
metaProperty(String propertyName)
          Gets a meta-property by name.
 int metaPropertyCount()
          Counts the number of properties.
 boolean metaPropertyExists(String propertyName)
          Checks if a property exists.
 Iterable<MetaProperty<?>> metaPropertyIterable()
          Gets an iterator of meta-properties.
 Map<String,MetaProperty<?>> metaPropertyMap()
          Gets the map of meta-properties, keyed by property name.
static
<B extends Bean>
ReflectiveMetaBean
of(Class<B> beanClass)
          Factory to create a meta-bean avoiding duplicate generics.
 String toString()
          Returns a string that summarises the meta-bean.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static <B extends Bean> ReflectiveMetaBean of(Class<B> beanClass)
Factory to create a meta-bean avoiding duplicate generics.

Type Parameters:
B - the type of the bean
Parameters:
beanClass - the bean class, not null
Returns:
the meta-bean, not null

builder

public BeanBuilder<Bean> builder()
Description copied from interface: MetaBean
Creates a bean builder that can be used to create an instance of this bean.

Specified by:
builder in interface MetaBean
Returns:
the bean builder, not null

createPropertyMap

public PropertyMap createPropertyMap(Bean bean)
Description copied from interface: MetaBean
Creates a map of properties for the specified bean.

Specified by:
createPropertyMap in interface MetaBean
Parameters:
bean - the bean to create the map for, not null
Returns:
the created property map, not null

beanName

public String beanName()
Description copied from interface: MetaBean
Gets the bean name, which is normally the fully qualified class name of the bean.

Specified by:
beanName in interface MetaBean
Returns:
the name of the bean, not empty

beanType

public Class<? extends Bean> beanType()
Description copied from interface: MetaBean
Get the type of the bean represented as a Class.

Specified by:
beanType in interface MetaBean
Returns:
the type of the bean, not null

metaPropertyCount

public int metaPropertyCount()
Description copied from interface: MetaBean
Counts the number of properties.

Specified by:
metaPropertyCount in interface MetaBean
Returns:
the number of properties

metaPropertyExists

public boolean metaPropertyExists(String propertyName)
Description copied from interface: MetaBean
Checks if a property exists.

Specified by:
metaPropertyExists in interface MetaBean
Parameters:
propertyName - the property name to check, null returns false
Returns:
true if the property exists

metaProperty

public <R> MetaProperty<R> metaProperty(String propertyName)
Description copied from interface: MetaBean
Gets a meta-property by name.

The base interface throws an exception if the name is not recognised. By contrast, the DynamicMetaBean subinterface creates the property on demand.

Specified by:
metaProperty in interface MetaBean
Type Parameters:
R - the property type, optional, enabling auto-casting
Parameters:
propertyName - the property name to retrieve, not null
Returns:
the meta property, not null

metaPropertyIterable

public Iterable<MetaProperty<?>> metaPropertyIterable()
Description copied from interface: MetaBean
Gets an iterator of meta-properties.

This method returns an Iterable, which is simpler than a Map. As a result, implementations may be able to optimise, and so this method should be preferred to MetaBean.metaPropertyMap() where a choice is possible.

Specified by:
metaPropertyIterable in interface MetaBean
Returns:
the unmodifiable map of meta property objects, not null

metaPropertyMap

public Map<String,MetaProperty<?>> metaPropertyMap()
Description copied from interface: MetaBean
Gets the map of meta-properties, keyed by property name.

Where possible, use MetaBean.metaPropertyIterable() instead.

Specified by:
metaPropertyMap in interface MetaBean
Returns:
the unmodifiable map of meta property objects, not null

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

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

Overrides:
toString in class Object
Returns:
a summary string, not null


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