net.sf.japaki.beans
Class TransformProperty<B,S,V>

java.lang.Object
  extended by net.sf.japaki.beans.TransformProperty<B,S,V>
All Implemented Interfaces:
Property<B,V>

public class TransformProperty<B,S,V>
extends Object
implements Property<B,V>

A property that transforms a value after reading it from the bean.


Method Summary
 Class<V> getType()
          Returns null.
 V getValue(B bean)
          Retrieves the value of this property from the specified bean and transforms it with the underlying transformer.
static
<B,S,V> Property<B,V>
newInstance(Property<B,S> base, TwoWayTransformer<S,V> transformer)
          Constructs a new transform property.
 void setValue(B bean, V value)
          Retransforms the specified value with the underlying transformer and stores it in the specified bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <B,S,V> Property<B,V> newInstance(Property<B,S> base,
                                                TwoWayTransformer<S,V> transformer)
Constructs a new transform property.

Parameters:
base - underlying property
transformer - underlying transformers
Returns:
a new transform property
Throws:
NullPointerException - if any parameter is null.

getValue

public V getValue(B bean)
Retrieves the value of this property from the specified bean and transforms it with the underlying transformer.

Specified by:
getValue in interface Property<B,V>
Parameters:
bean - the bean from which to read the value
Returns:
the transformed value
Throws:
ClassCastException - depending on the underlying property and transformer
NullPointerException - if bean is null.
IllegalArgumentException - depending on the underlying property and transformer

setValue

public void setValue(B bean,
                     V value)
Retransforms the specified value with the underlying transformer and stores it in the specified bean.

Specified by:
setValue in interface Property<B,V>
Parameters:
bean - the bean in which to store the (retransformed) value
value - the value of the property in the target space of the transformation
Throws:
UnsupportedOperationException - if the underlying property is read-only or the transformer is one-way
ClassCastException - depending on the underlying property and transformer
NullPointerException - if bean is null or if the specified value is null and the bean does not permit null values
IllegalArgumentException - depending on the underlying property and transformer
IllegalStateException - depending on the underlying property

getType

public Class<V> getType()
Returns null.

Specified by:
getType in interface Property<B,V>
Returns:
null