Interface Property<P>
-
- Type Parameters:
P- the type of the property content
- All Known Implementing Classes:
BasicProperty
public interface Property<P>A property that is linked to a specific bean.For a JavaBean, this will ultimately wrap a get/set method pair. Alternate implementations may perform any logic to obtain the value.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <B extends Bean>
Bbean()Gets the bean which owns this property.booleanequals(Object obj)Checks if this property equals another.default Pget()Gets the value of the property for the associated bean.inthashCode()Returns a suitable hash code.MetaProperty<P>metaProperty()Gets the meta-property representing the parts of the property that are common across all instances, such as the name.default Stringname()Gets the property name.default Pput(Object value)Sets the value of the property on the associated bean and returns the previous value.default voidset(Object value)Sets the value of the property on the associated bean.
-
-
-
Method Detail
-
bean
<B extends Bean> B bean()
Gets the bean which owns this property.Each property is fully owned by a single bean.
- Type Parameters:
B- the bean type- Returns:
- the bean, not null
-
metaProperty
MetaProperty<P> metaProperty()
Gets the meta-property representing the parts of the property that are common across all instances, such as the name.- Returns:
- the meta-property, not null
-
name
default String name()
Gets the property name.The JavaBean style methods getFoo() and setFoo() will lead to a property name of 'foo' and so on.
- Returns:
- the name of the property, not empty
-
get
default P get()
Gets the value of the property for the associated bean.For a JavaBean, this is the equivalent to calling
getFoo()on the bean itself. Alternate implementations may perform any logic to obtain the value.- Returns:
- the value of the property on the bound bean, may be null
- Throws:
UnsupportedOperationException- if the property is write-only
-
set
default void set(Object value)
Sets the value of the property on the associated bean.The value must be of the correct type for the property. See the meta-property for string conversion. For a standard JavaBean, this is equivalent to calling
setFoo()on the bean. Alternate implementations may perform any logic to change the value.- Parameters:
value- the value to set into the property on the bean- Throws:
ClassCastException- if the value is of an invalid type for the propertyUnsupportedOperationException- if the property is read-onlyRuntimeException- if the value is rejected by the property (use appropriate subclasses)
-
put
default P put(Object value)
Sets the value of the property on the associated bean and returns the previous value.This is a combination of the
getandsetmethods that matches the definition ofputin aMap.- Parameters:
value- the value to set into the property on the bean- Returns:
- the old value of the property, may be null
- Throws:
ClassCastException- if the value is of an invalid type for the propertyUnsupportedOperationException- if the property is read-onlyRuntimeException- if the value is rejected by the property (use appropriate subclasses)
-
equals
boolean equals(Object obj)
Checks if this property equals another.This compares the meta-property and value. It does not consider the property or bean types.
-
-