net.sf.japaki.beans
Class ConstantProperty<V>

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

public class ConstantProperty<V>
extends Object
implements Property<Object,V>

A property that always returns the same value instead of retrieving it from a bean.


Method Summary
 Class<V> getType()
          Returns the class of the stored value.
 V getValue(Object bean)
          Returns the stored value.
static
<V> Property<Object,V>
newInstance(V value)
          Constructs a constant property using the given value.
 void setValue(Object bean, V value)
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <V> Property<Object,V> newInstance(V value)
Constructs a constant property using the given value.

Parameters:
value - a constant. null is allowed.
Returns:
a constant property using the given value

getValue

public V getValue(Object bean)
Returns the stored value.

Specified by:
getValue in interface Property<Object,V>
Parameters:
bean - ignored
Returns:
a constant value

setValue

public void setValue(Object bean,
                     V value)
Does nothing.

Specified by:
setValue in interface Property<Object,V>
Parameters:
bean - ignored
value - ignored
Throws:
IllegalArgumentException - if the specified value does not equal the constant

getType

public Class<V> getType()
Returns the class of the stored value.

Specified by:
getType in interface Property<Object,V>
Returns:
the class of the stored value