org.joda.beans
Class StandardMetaProperty<B,P>

java.lang.Object
  extended by org.joda.beans.StandardMetaProperty<B,P>
Type Parameters:
B - the type of the bean
P - the type of the property content
All Implemented Interfaces:
MetaProperty<B,P>

public final class StandardMetaProperty<B,P>
extends Object
implements MetaProperty<B,P>

A meta-property implemented using a PropertyDescriptor.

The property descriptor class is part of the JDK JavaBean standard. It provides access to get and set a property on a bean.

Author:
Stephen Colebourne

Method Summary
 Class<B> beanClass()
          Get the type of the bean represented as a Class.
 Property<B,P> createProperty(B bean)
          Creates a property that binds this meta-property to a specific bean.
 P get(B bean)
          Gets the value of the bound property for the provided bean.
 String name()
          Gets the property name.
static
<B,P> StandardMetaProperty<B,P>
of(Class<B> beanType, String propertyName)
          Factory to create a meta-property avoiding duplicate generics.
 Class<P> propertyClass()
          Get the type of the property represented as a Class.
 ReadWriteProperty readWrite()
          Gets whether the property is read-only, read-write or write-only.
 void set(B bean, P value)
          Sets the value of the bound property on the provided bean.
 String toString()
          Returns a string that summarizes the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static <B,P> StandardMetaProperty<B,P> of(Class<B> beanType,
                                                 String propertyName)
Factory to create a meta-property avoiding duplicate generics.

Parameters:
beanType - the bean type
propertyName - the property name

createProperty

public Property<B,P> createProperty(B bean)
Description copied from interface: MetaProperty
Creates a property that binds this meta-property to a specific bean.

Specified by:
createProperty in interface MetaProperty<B,P>
Parameters:
bean - the bean to create the property for, not null
Returns:
the property, never null

name

public String name()
Description copied from interface: MetaProperty
Gets the property name.

The JavaBean style methods getFoo() and setFoo() will lead to a property name of 'foo' and so on.

Specified by:
name in interface MetaProperty<B,P>
Returns:
the name of the property, never null

propertyClass

public Class<P> propertyClass()
Description copied from interface: MetaProperty
Get the type of the property represented as a Class.

Specified by:
propertyClass in interface MetaProperty<B,P>
Returns:
the type of the property, never null

beanClass

public Class<B> beanClass()
Description copied from interface: MetaProperty
Get the type of the bean represented as a Class.

Specified by:
beanClass in interface MetaProperty<B,P>
Returns:
the type of the bean, never null

readWrite

public ReadWriteProperty readWrite()
Description copied from interface: MetaProperty
Gets whether the property is read-only, read-write or write-only.

Specified by:
readWrite in interface MetaProperty<B,P>
Returns:
the property read-write type, never null

get

public P get(B bean)
Gets the value of the bound property for the provided bean.

This is the equivalent to calling getFoo() on the bean itself. However some implementations of this interface may not require an actual get method.

Specified by:
get in interface MetaProperty<B,P>
Parameters:
bean - the bean to query, not null
Returns:
the value of the property on the bound bean
Throws:
UnsupportedOperationException - if the property is write-only

set

public void set(B bean,
                P value)
Sets the value of the bound property on the provided bean.

This is the equivalent to calling setFoo() on the bean itself. However some implementations of this interface may not require an actual set method.

Specified by:
set in interface MetaProperty<B,P>
Parameters:
bean - the bean to update, not null
value - the value to set into the property on the bound bean
Throws:
UnsupportedOperationException - if the property is read-only

toString

public String toString()
Returns a string that summarizes the property.

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


Copyright © 2007-2010 Joda.org. All Rights Reserved.