org.joda.beans
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
<B extends Bean>
B
bean()
          Gets the bean which owns this property.
 boolean equals(Object obj)
          Checks if this property equals another.
 P get()
          Gets the value of the property for the associated bean.
 int hashCode()
          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.
 String name()
          Gets the property name.
 P put(Object value)
          Sets the value of the property on the associated bean and returns the previous value.
 void set(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

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

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

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 property
UnsupportedOperationException - if the property is read-only
RuntimeException - if the value is rejected by the property (use appropriate subclasses)

put

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 get and set methods that matches the definition of put in a Map.

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 property
UnsupportedOperationException - if the property is read-only
RuntimeException - 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.

Overrides:
equals in class Object
Parameters:
obj - the other property, null returns false
Returns:
true if equal

hashCode

int hashCode()
Returns a suitable hash code.

Overrides:
hashCode in class Object
Returns:
the hash code


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