org.joda.beans.impl
Class BasicMetaProperty<P>

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

public abstract class BasicMetaProperty<P>
extends Object
implements MetaProperty<P>

An abstract base meta-property.


Constructor Summary
protected BasicMetaProperty(String propertyName)
          Constructor.
 
Method Summary
<A extends Annotation>
A
annotation(Class<A> annotationClass)
          Gets a specified annotation of the property.
 Property<P> createProperty(Bean bean)
          Creates a property that binds this meta-property to a specific bean.
 boolean equals(Object obj)
          Checks if this meta-property equals another.
 String getString(Bean bean)
          Gets the value of the property for the specified bean converted to a string.
 String getString(Bean bean, org.joda.convert.StringConvert stringConvert)
          Gets the value of the property for the specified bean converted to a string.
 int hashCode()
          Returns a suitable hash code.
 String name()
          Gets the property name.
 P put(Bean bean, Object value)
          Sets the value of the property on the associated bean and returns the previous value.
 void setString(Bean bean, String value)
          Sets the value of the property on the specified bean from a string by conversion.
 void setString(Bean bean, String value, org.joda.convert.StringConvert stringConvert)
          Sets the value of the property on the specified bean from a string by conversion.
 String toString()
          Returns a string that summarises the meta-property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.beans.MetaProperty
annotations, declaringType, get, metaBean, propertyGenericType, propertyType, set, style
 

Constructor Detail

BasicMetaProperty

protected BasicMetaProperty(String propertyName)
Constructor.

Parameters:
propertyName - the property name, not empty
Method Detail

createProperty

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

Specified by:
createProperty in interface MetaProperty<P>
Parameters:
bean - the bean to create the property for, not null
Returns:
the property, not 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<P>
Returns:
the name of the property, not empty

put

public P put(Bean bean,
             Object value)
Description copied from interface: MetaProperty
Sets the value of the property on the associated bean and returns the previous value.

The value must be of the correct type for the property. This is a combination of the get and set methods that matches the definition of put in a Map.

Specified by:
put in interface MetaProperty<P>
Parameters:
bean - the bean to update, not null
value - the value to set into the property on the specified bean, may be null
Returns:
the old value of the property, may be null

getString

public String getString(Bean bean)
Description copied from interface: MetaProperty
Gets the value of the property for the specified bean converted to a string.

This converts the result of MetaProperty.get(Bean) to a standard format string. Conversion uses Joda-Convert. Not all object types can be converted to a string, see Joda-Convert.

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

Specified by:
getString in interface MetaProperty<P>
Parameters:
bean - the bean to query, not null
Returns:
the value of the property on the specified bean, may be null

getString

public String getString(Bean bean,
                        org.joda.convert.StringConvert stringConvert)
Description copied from interface: MetaProperty
Gets the value of the property for the specified bean converted to a string.

This converts the result of MetaProperty.get(Bean) to a standard format string using the supplied converter. Not all object types can be converted to a string, see Joda-Convert.

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

Specified by:
getString in interface MetaProperty<P>
Parameters:
bean - the bean to query, not null
stringConvert - the converter to use, not null
Returns:
the value of the property on the specified bean, may be null

setString

public void setString(Bean bean,
                      String value)
Description copied from interface: MetaProperty
Sets the value of the property on the specified bean from a string by conversion.

This converts the string to the correct type for the property and then sets it using MetaProperty.set(Bean, Object). Conversion uses Joda-Convert.

Specified by:
setString in interface MetaProperty<P>
Parameters:
bean - the bean to update, not null
value - the value to set into the property on the specified bean, may be null

setString

public void setString(Bean bean,
                      String value,
                      org.joda.convert.StringConvert stringConvert)
Description copied from interface: MetaProperty
Sets the value of the property on the specified bean from a string by conversion.

This converts the string to the correct type for the property using the supplied converter and then sets it using MetaProperty.set(Bean, Object).

Specified by:
setString in interface MetaProperty<P>
Parameters:
bean - the bean to update, not null
value - the value to set into the property on the specified bean, may be null
stringConvert - the converter, 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>
Type Parameters:
A - the annotation type
Parameters:
annotationClass - the annotation class to find, not null
Returns:
the annotation, not null

equals

public boolean equals(Object obj)
Description copied from interface: MetaProperty
Checks if this meta-property equals another.

This compares the property name and declaring type. It does not compare the property or bean types.

Specified by:
equals in interface MetaProperty<P>
Overrides:
equals in class Object
Parameters:
obj - the other meta-property, null returns false
Returns:
true if equal

hashCode

public int hashCode()
Description copied from interface: MetaProperty
Returns a suitable hash code.

Specified by:
hashCode in interface MetaProperty<P>
Overrides:
hashCode in class Object
Returns:
the hash code

toString

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

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


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