org.joda.beans
Class DescriptorMetaProperty<B,T>

java.lang.Object
  extended by org.joda.beans.DescriptorMetaProperty<B,T>
All Implemented Interfaces:
MetaProperty<B,T>

public class DescriptorMetaProperty<B,T>
extends Object
implements MetaProperty<B,T>

A property is a field on a bean that can typically be called via get/set.

Author:
Stephen Colebourne

Constructor Summary
DescriptorMetaProperty(Class<B> beanType, String propertyName)
          Constructor.
 
Method Summary
 Property<B,T> createProperty(B bean)
          Creates a property that binds this meta property to a specific bean.
 T get(B bean)
          Gets the value of the bound property for the provided bean.
 Class<B> getBeanType()
          Get the type of the bean represented as a Class.
 String getName()
          Gets the property name.
 ReadWriteProperty getReadWrite()
          Gets whether the property is read-write, read-only or write-only.
 Class<T> getType()
          Get the type of the property represented as a Class.
 void set(B bean, T value)
          Sets the value of the bound property on the provided bean.
 String toString()
          Returns a debugging string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescriptorMetaProperty

public DescriptorMetaProperty(Class<B> beanType,
                              String propertyName)
Constructor.

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

createProperty

public Property<B,T> createProperty(B bean)
Creates a property that binds this meta property to a specific bean.

Specified by:
createProperty in interface MetaProperty<B,T>
Parameters:
bean - the bean to create the bound property for
Returns:
the bound property

getName

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

Specified by:
getName in interface MetaProperty<B,T>
Returns:
the name of the property

getType

public Class<T> getType()
Get the type of the property represented as a Class.

Specified by:
getType in interface MetaProperty<B,T>
Returns:
the type of the property

getBeanType

public Class<B> getBeanType()
Get the type of the bean represented as a Class.

Specified by:
getBeanType in interface MetaProperty<B,T>
Returns:
the type of the bean

getReadWrite

public ReadWriteProperty getReadWrite()
Gets whether the property is read-write, read-only or write-only.

Specified by:
getReadWrite in interface MetaProperty<B,T>
Returns:
the property read-write type

get

public T 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,T>
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,
                T 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,T>
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 debugging string.

Overrides:
toString in class Object
Returns:
a debugging string


Copyright © 2007 Joda.org. All Rights Reserved.