org.joda.beans.impl.direct
Class DirectMetaProperty<P>

java.lang.Object
  extended by org.joda.beans.impl.BasicMetaProperty<P>
      extended by org.joda.beans.impl.direct.DirectMetaProperty<P>
Type Parameters:
P - the type of the property content
All Implemented Interfaces:
BeanQuery<P>, MetaProperty<P>

public final class DirectMetaProperty<P>
extends BasicMetaProperty<P>

A meta-property implementation designed for use by the code generator.

This meta-property uses reflection to find the Field to obtain the annotations.


Method Summary
<A extends Annotation>
A
annotation(Class<A> annotationClass)
          Gets a specified annotation of the property.
 List<Annotation> annotations()
          Gets the annotations of the property.
 Class<?> declaringType()
          Get the type that declares the property, represented as a Class.
 P get(Bean bean)
          Gets the value of the property for the specified bean.
 MetaBean metaBean()
          Gets the meta-bean which owns this meta-property.
static
<P> DirectMetaProperty<P>
ofDerived(MetaBean metaBean, String propertyName, Class<?> declaringType, Class<P> propertyType)
          Factory to create a derived read-only meta-property avoiding duplicate generics.
static
<P> DirectMetaProperty<P>
ofImmutable(MetaBean metaBean, String propertyName, Class<?> declaringType, Class<P> propertyType)
          Factory to create an imutable meta-property avoiding duplicate generics.
static
<P> DirectMetaProperty<P>
ofReadOnly(MetaBean metaBean, String propertyName, Class<?> declaringType, Class<P> propertyType)
          Factory to create a read-write meta-property avoiding duplicate generics.
static
<P> DirectMetaProperty<P>
ofReadWrite(MetaBean metaBean, String propertyName, Class<?> declaringType, Class<P> propertyType)
          Factory to create a read-write meta-property avoiding duplicate generics.
static
<P> DirectMetaProperty<P>
ofWriteOnly(MetaBean metaBean, String propertyName, Class<?> declaringType, Class<P> propertyType)
          Factory to create a read-write meta-property avoiding duplicate generics.
 Type propertyGenericType()
          Gets the generic types of the property.
 Class<P> propertyType()
          Get the type of the property represented as a Class.
 void set(Bean bean, Object value)
          Sets the value of the property on the specified bean.
 PropertyStyle style()
          Gets the style of the property, such as read-only, read-write or write-only.
 
Methods inherited from class org.joda.beans.impl.BasicMetaProperty
createProperty, equals, getString, getString, hashCode, name, put, setString, setString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

ofReadWrite

public static <P> DirectMetaProperty<P> ofReadWrite(MetaBean metaBean,
                                                    String propertyName,
                                                    Class<?> declaringType,
                                                    Class<P> propertyType)
Factory to create a read-write meta-property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
metaBean - the meta-bean, not null
propertyName - the property name, not empty
declaringType - the type declaring the property, not null
propertyType - the property type, not null
Returns:
the property, not null

ofReadOnly

public static <P> DirectMetaProperty<P> ofReadOnly(MetaBean metaBean,
                                                   String propertyName,
                                                   Class<?> declaringType,
                                                   Class<P> propertyType)
Factory to create a read-write meta-property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
metaBean - the meta-bean, not null
propertyName - the property name, not empty
declaringType - the type declaring the property, not null
propertyType - the property type, not null
Returns:
the property, not null

ofWriteOnly

public static <P> DirectMetaProperty<P> ofWriteOnly(MetaBean metaBean,
                                                    String propertyName,
                                                    Class<?> declaringType,
                                                    Class<P> propertyType)
Factory to create a read-write meta-property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
metaBean - the meta-bean, not null
propertyName - the property name, not empty
declaringType - the type declaring the property, not null
propertyType - the property type, not null
Returns:
the property, not null

ofDerived

public static <P> DirectMetaProperty<P> ofDerived(MetaBean metaBean,
                                                  String propertyName,
                                                  Class<?> declaringType,
                                                  Class<P> propertyType)
Factory to create a derived read-only meta-property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
metaBean - the meta-bean, not null
propertyName - the property name, not empty
declaringType - the type declaring the property, not null
propertyType - the property type, not null
Returns:
the property, not null

ofImmutable

public static <P> DirectMetaProperty<P> ofImmutable(MetaBean metaBean,
                                                    String propertyName,
                                                    Class<?> declaringType,
                                                    Class<P> propertyType)
Factory to create an imutable meta-property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
metaBean - the meta-bean, not null
propertyName - the property name, not empty
declaringType - the type declaring the property, not null
propertyType - the property type, not null
Returns:
the property, not null

metaBean

public MetaBean metaBean()
Description copied from interface: MetaProperty
Gets the meta-bean which owns this meta-property.

Each meta-property is fully owned by a single bean.

Returns:
the meta-bean, not null

declaringType

public Class<?> declaringType()
Description copied from interface: MetaProperty
Get the type that declares the property, represented as a Class.

Returns:
the type declaring the property, not null

propertyType

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

Returns:
the type of the property, not null

propertyGenericType

public Type propertyGenericType()
Description copied from interface: MetaProperty
Gets the generic types of the property.

This provides access to the generic type declared in the source code.

Returns:
the full generic type of the property, unmodifiable, not null

style

public PropertyStyle style()
Description copied from interface: MetaProperty
Gets the style of the property, such as read-only, read-write or write-only.

Returns:
the property style, not null

annotation

public <A extends Annotation> A annotation(Class<A> annotationClass)
Description copied from interface: MetaProperty
Gets a specified annotation of the property.

Specified by:
annotation in interface MetaProperty<P>
Overrides:
annotation in class BasicMetaProperty<P>
Type Parameters:
A - the annotation type
Parameters:
annotationClass - the annotation class to find, not null
Returns:
the annotation, not null

annotations

public List<Annotation> annotations()
Description copied from interface: MetaProperty
Gets the annotations of the property.

Returns:
the annotations, unmodifiable, not null

get

public P get(Bean bean)
Description copied from interface: MetaProperty
Gets the value of the property for the specified bean.

For a standard JavaBean, this is equivalent to calling getFoo() on the bean. Alternate implementations may perform any logic to obtain the value.

Parameters:
bean - the bean to query, not null
Returns:
the value of the property on the specified bean, may be null

set

public void set(Bean bean,
                Object value)
Description copied from interface: MetaProperty
Sets the value of the property on the specified bean.

The value must be of the correct type for the property. For a standard JavaBean, this is equivalent to calling setFoo() on the bean. Alternate implementations may perform any logic to change the value.

Parameters:
bean - the bean to update, not null
value - the value to set into the property on the specified bean, may be null


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