- java.lang.Object
-
- org.joda.beans.impl.BasicMetaProperty<P>
-
- org.joda.beans.impl.direct.DirectMetaProperty<P>
-
- Type Parameters:
P- the type of the property content
- All Implemented Interfaces:
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
Fieldto obtain the annotations.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends java.lang.annotation.Annotation>
Aannotation(java.lang.Class<A> annotationClass)Gets an annotation from the property.java.util.List<java.lang.annotation.Annotation>annotations()Gets the annotations of the property.java.lang.Class<?>declaringType()Get the type that declares the property, represented as aClass.Pget(Bean bean)Gets the value of the property for the specified bean.MetaBeanmetaBean()Gets the meta-bean which owns this meta-property.static <P> DirectMetaProperty<P>ofDerived(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create a derived read-only meta-property avoiding duplicate generics.static <P> DirectMetaProperty<P>ofImmutable(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create an imutable meta-property avoiding duplicate generics.static <P> DirectMetaProperty<P>ofReadOnly(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create a read-only meta-property avoiding duplicate generics.static <P> DirectMetaProperty<P>ofReadOnlyBuildable(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create a buildable read-only meta-property avoiding duplicate generics.static <P> DirectMetaProperty<P>ofReadWrite(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create a read-write meta-property avoiding duplicate generics.static <P> DirectMetaProperty<P>ofWriteOnly(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)Factory to create a write-only meta-property avoiding duplicate generics.java.lang.reflect.TypepropertyGenericType()Gets the generic types of the property.java.lang.Class<P>propertyType()Get the type of the property represented as aClass.voidset(Bean bean, java.lang.Object value)Sets the value of the property on the specified bean.PropertyStylestyle()Gets the style of the property, such as read-only, read-write or write-only.-
Methods inherited from class org.joda.beans.impl.BasicMetaProperty
equals, hashCode, name, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.joda.beans.MetaProperty
createProperty, getString, getString, put, setString, setString
-
-
-
-
Method Detail
-
ofReadWrite
public static <P> DirectMetaProperty<P> ofReadWrite(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.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 nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
ofReadOnly
public static <P> DirectMetaProperty<P> ofReadOnly(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)
Factory to create a read-only meta-property avoiding duplicate generics.- Type Parameters:
P- the property type- Parameters:
metaBean- the meta-bean, not nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
ofWriteOnly
public static <P> DirectMetaProperty<P> ofWriteOnly(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)
Factory to create a write-only meta-property avoiding duplicate generics.- Type Parameters:
P- the property type- Parameters:
metaBean- the meta-bean, not nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
ofReadOnlyBuildable
public static <P> DirectMetaProperty<P> ofReadOnlyBuildable(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.Class<P> propertyType)
Factory to create a buildable read-only meta-property avoiding duplicate generics.- Type Parameters:
P- the property type- Parameters:
metaBean- the meta-bean, not nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
ofDerived
public static <P> DirectMetaProperty<P> ofDerived(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.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 nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
ofImmutable
public static <P> DirectMetaProperty<P> ofImmutable(MetaBean metaBean, java.lang.String propertyName, java.lang.Class<?> declaringType, java.lang.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 nullpropertyName- the property name, not emptydeclaringType- the type declaring the property, not nullpropertyType- the property type, not null- Returns:
- the property, not null
-
metaBean
public MetaBean metaBean()
Description copied from interface:MetaPropertyGets 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 java.lang.Class<?> declaringType()
Description copied from interface:MetaPropertyGet the type that declares the property, represented as aClass.This is the type of the bean where the property is declared.
- Returns:
- the type declaring the property, not null
-
propertyType
public java.lang.Class<P> propertyType()
Description copied from interface:MetaPropertyGet the type of the property represented as aClass.This is the type of the property. For example, the surname of a person would typically be a
String.- Returns:
- the type of the property, not null
-
propertyGenericType
public java.lang.reflect.Type propertyGenericType()
Description copied from interface:MetaPropertyGets 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:MetaPropertyGets the style of the property, such as read-only, read-write or write-only.Rather than testing against specific values, it is strongly recommended to call the helper methods on the returned style.
- Returns:
- the property style, not null
-
annotation
public <A extends java.lang.annotation.Annotation> A annotation(java.lang.Class<A> annotationClass)
Description copied from interface:MetaPropertyGets an annotation from the property.The annotations are queried from the property. This is typically accomplished by querying the annotations of the underlying instance variable however any strategy is permitted..
- Type Parameters:
A- the annotation type- Parameters:
annotationClass- the annotation class to find, not null- Returns:
- the annotation, not null
-
annotations
public java.util.List<java.lang.annotation.Annotation> annotations()
Description copied from interface:MetaPropertyGets the annotations of the property.The annotations are queried from the property. This is typically accomplished by querying the annotations of the underlying instance variable however any strategy is permitted.
- Returns:
- the annotations, unmodifiable, not null
-
get
public P get(Bean bean)
Description copied from interface:MetaPropertyGets 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, java.lang.Object value)
Description copied from interface:MetaPropertySets 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 nullvalue- the value to set into the property on the specified bean, may be null
-
-