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

java.lang.Object
  extended by org.joda.beans.impl.BasicProperty<P>
Type Parameters:
P - the type of the property content
All Implemented Interfaces:
Property<P>

public final class BasicProperty<P>
extends Object
implements Property<P>

A property that binds a Bean to a MetaProperty.

This is the standard implementation of a property. It defers the strategy of getting and setting the value to the meta-property.

This implementation is also a map entry to aid performance in maps.


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.
static
<P> BasicProperty<P>
of(Bean bean, MetaProperty<P> metaProperty)
          Factory to create a property avoiding duplicate generics.
 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.
 String toString()
          Returns a string that summarises the property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static <P> BasicProperty<P> of(Bean bean,
                                      MetaProperty<P> metaProperty)
Factory to create a property avoiding duplicate generics.

Type Parameters:
P - the property type
Parameters:
bean - the bean that the property is bound to, not null
metaProperty - the meta property, not null
Returns:
the property, not null

bean

public <B extends Bean> B bean()
Description copied from interface: Property
Gets the bean which owns this property.

Each property is fully owned by a single bean.

Specified by:
bean in interface Property<P>
Type Parameters:
B - the bean type
Returns:
the bean, not null

metaProperty

public MetaProperty<P> metaProperty()
Description copied from interface: Property
Gets the meta-property representing the parts of the property that are common across all instances, such as the name.

Specified by:
metaProperty in interface Property<P>
Returns:
the meta-property, not null

name

public String name()
Description copied from interface: Property
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 Property<P>
Returns:
the name of the property, not empty

get

public P get()
Description copied from interface: Property
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.

Specified by:
get in interface Property<P>
Returns:
the value of the property on the bound bean, may be null

set

public void set(Object value)
Description copied from interface: Property
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.

Specified by:
set in interface Property<P>
Parameters:
value - the value to set into the property on the bean

put

public P put(Object value)
Description copied from interface: Property
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.

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

equals

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

This compares the meta-property and value. It does not consider the property or bean types.

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

hashCode

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

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

toString

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

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


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