org.joda.beans
Class StandardProperty<B,P>

java.lang.Object
  extended by org.joda.beans.StandardProperty<B,P>
Type Parameters:
B - the type of the bean
P - the type of the property content
All Implemented Interfaces:
Map.Entry<String,Property<B,P>>, Property<B,P>

public final class StandardProperty<B,P>
extends Object
implements Property<B,P>, Map.Entry<String,Property<B,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

Author:
Stephen Colebourne

Method Summary
 B bean()
          Gets the bean which owns this property.
 boolean equals(Object obj)
           
 P get()
          Gets the value of the property for the associated bean.
 String getKey()
           
 Property<B,P> getValue()
           
 int hashCode()
           
 MetaProperty<B,P> metaProperty()
          Gets the meta-property representing the parts of the property that are common across all instances, such as the name.
static
<B,P> StandardProperty<B,P>
of(B bean, MetaProperty<B,P> metaProperty)
          Factory to create a property avoiding duplicate generics.
 void set(P value)
          Sets the value of the property on the associated bean.
 Property<B,P> setValue(Property<B,P> value)
           
 String toString()
          Returns a string that summarizes the property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

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

Parameters:
bean - the bean that the property is bound to, not null
metaProperty - the meta property, not null

bean

public 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<B,P>
Returns:
the bean, never null

metaProperty

public MetaProperty<B,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<B,P>
Returns:
the meta-property, never null

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<B,P>
Returns:
the value of the property on the bound bean

set

public void set(P value)
Description copied from interface: Property
Sets the value of the property on the associated bean.

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<B,P>
Parameters:
value - the value to set into the property on the bean

getKey

public String getKey()
Specified by:
getKey in interface Map.Entry<String,Property<B,P>>

getValue

public Property<B,P> getValue()
Specified by:
getValue in interface Map.Entry<String,Property<B,P>>

setValue

public Property<B,P> setValue(Property<B,P> value)
Specified by:
setValue in interface Map.Entry<String,Property<B,P>>

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map.Entry<String,Property<B,P>>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map.Entry<String,Property<B,P>>
Overrides:
hashCode in class Object

toString

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

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


Copyright © 2007-2010 Joda.org. All Rights Reserved.