net.sf.japaki.basic
Class NumberTransformer<T extends Number>

java.lang.Object
  extended by net.sf.japaki.basic.NumberTransformer<T>
All Implemented Interfaces:
TwoWayTransformer<T,Number>

public abstract class NumberTransformer<T extends Number>
extends Object
implements TwoWayTransformer<T,Number>

Transforms a number to a specific type value.


Method Summary
static
<T extends Number>
TwoWayTransformer<T,Number>
getInstance(Class<T> type)
          Returns a transformer, that transforms instances of the specified class to a number.
 boolean isRetrievable(Number input)
          Indicates if the input value can be converted to type T.
 Number transform(T input)
          Transforms the input value to a number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.japaki.basic.TwoWayTransformer
retransform
 

Method Detail

transform

public Number transform(T input)
Transforms the input value to a number.

Specified by:
transform in interface TwoWayTransformer<T extends Number,Number>
Parameters:
input - a number of type T
Returns:
a number representation of the input value

isRetrievable

public boolean isRetrievable(Number input)
Indicates if the input value can be converted to type T.

Specified by:
isRetrievable in interface TwoWayTransformer<T extends Number,Number>
Parameters:
input - the object for which the transformation origin is searched.
Returns:
true, iff the input value can be converted to type T.

getInstance

public static final <T extends Number> TwoWayTransformer<T,Number> getInstance(Class<T> type)
Returns a transformer, that transforms instances of the specified class to a number. Possible types are: Integer, Long, Float, Double, Byte, Short, AtomicInteger, AtomicLong.

Parameters:
type - type of input parameter to the transformer
Returns:
a number transformer for the specified class
Throws:
NullPointerException - if type is null
IllegalArgumentException - if type is not known