P - the type of the property contentBasicMetaProperty, DirectMetaProperty, StandaloneMetaPropertypublic interface MetaProperty<P>
| Modifier and Type | Method | Description |
|---|---|---|
default <A extends java.lang.annotation.Annotation> |
annotation(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.
|
default Property<P> |
createProperty(Bean bean) |
Creates a property that binds this meta-property to a specific bean.
|
java.lang.Class<?> |
declaringType() |
Get the type that declares the property, represented as a
Class. |
boolean |
equals(java.lang.Object obj) |
Checks if this meta-property equals another.
|
P |
get(Bean bean) |
Gets the value of the property for the specified bean.
|
default java.lang.String |
getString(Bean bean) |
Gets the value of the property for the specified bean converted to a string.
|
default java.lang.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.
|
MetaBean |
metaBean() |
Gets the meta-bean which owns this meta-property.
|
java.lang.String |
name() |
Gets the property name.
|
java.lang.reflect.Type |
propertyGenericType() |
Gets the generic types of the property.
|
java.lang.Class<P> |
propertyType() |
Get the type of the property represented as a
Class. |
default P |
put(Bean bean,
java.lang.Object value) |
Sets the value of the property on the associated bean and returns the previous value.
|
void |
set(Bean bean,
java.lang.Object value) |
Sets the value of the property on the specified bean.
|
default void |
setString(Bean bean,
java.lang.String value) |
Sets the value of the property on the specified bean from a string by conversion.
|
default void |
setString(Bean bean,
java.lang.String value,
org.joda.convert.StringConvert stringConvert) |
Sets the value of the property on the specified bean from a string by conversion.
|
PropertyStyle |
style() |
Gets the style of the property, such as read-only, read-write or write-only.
|
default Property<P> createProperty(Bean bean)
This method returns a Property instance that connects this meta-property to the specified bean.
The result can be queried and passed around without further reference to the bean.
bean - the bean to create the property for, not nullMetaBean metaBean()
Each meta-property is fully owned by a single bean.
java.lang.String name()
The JavaBean style methods getFoo() and setFoo() will lead to a property name of 'foo' and so on.
java.lang.Class<?> declaringType()
Class.
This is the type of the bean where the property is declared.
java.lang.Class<P> propertyType()
Class.
This is the type of the property.
For example, the surname of a person would typically be a String.
java.lang.reflect.Type propertyGenericType()
This provides access to the generic type declared in the source code.
PropertyStyle style()
Rather than testing against specific values, it is strongly recommended to call the helper methods on the returned style.
java.util.List<java.lang.annotation.Annotation> annotations()
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.
default <A extends java.lang.annotation.Annotation> A annotation(java.lang.Class<A> annotationClass)
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..
A - the annotation typeannotationClass - the annotation class to find, not nulljava.util.NoSuchElementException - if the annotation is not specifiedP get(Bean bean)
For a standard JavaBean, this is equivalent to calling getFoo() on the bean.
Alternate implementations may perform any logic to obtain the value.
bean - the bean to query, not nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.UnsupportedOperationException - if the property is write-onlyvoid set(Bean bean, java.lang.Object value)
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.
bean - the bean to update, not nullvalue - the value to set into the property on the specified bean, may be nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.ClassCastException - if the value is of an invalid type for the propertyjava.lang.UnsupportedOperationException - if the property is read-onlyjava.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)default P put(Bean bean, java.lang.Object 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.
bean - the bean to update, not nullvalue - the value to set into the property on the specified bean, may be nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.ClassCastException - if the value is of an invalid type for the propertyjava.lang.UnsupportedOperationException - if the property is read-onlyjava.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)default java.lang.String getString(Bean bean)
This converts the result of 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.
bean - the bean to query, not nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.UnsupportedOperationException - if the property is write-onlyjava.lang.RuntimeException - if the value cannot be converted to a string (use appropriate subclasses)default java.lang.String getString(Bean bean, org.joda.convert.StringConvert stringConvert)
This converts the result of 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.
bean - the bean to query, not nullstringConvert - the converter to use, not nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.UnsupportedOperationException - if the property is write-onlyjava.lang.RuntimeException - if the value cannot be converted to a string (use appropriate subclasses)default void setString(Bean bean, java.lang.String value)
This converts the string to the correct type for the property and then sets it
using set(Bean, Object). Conversion uses Joda-Convert.
bean - the bean to update, not nullvalue - the value to set into the property on the specified bean, may be nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.ClassCastException - if the value is of an invalid type for the propertyjava.lang.UnsupportedOperationException - if the property is read-onlyjava.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)default void setString(Bean bean, java.lang.String value, org.joda.convert.StringConvert stringConvert)
This converts the string to the correct type for the property using the supplied converter and then sets it
using set(Bean, Object).
bean - the bean to update, not nullvalue - the value to set into the property on the specified bean, may be nullstringConvert - the converter, not nulljava.lang.ClassCastException - if the bean is of an incorrect typejava.lang.ClassCastException - if the value is of an invalid type for the propertyjava.lang.UnsupportedOperationException - if the property is read-onlyjava.lang.RuntimeException - if the value is rejected by the property (use appropriate subclasses)boolean equals(java.lang.Object obj)
This compares the property name and declaring type. It does not compare the property or bean types.
equals in class java.lang.Objectobj - the other meta-property, null returns falseint hashCode()
hashCode in class java.lang.ObjectCopyright © 2007–2018 Joda.org. All rights reserved.