org.pfsw.reflect
Class NumericFieldProxy<T>

java.lang.Object
  extended by org.pfsw.reflect.FieldProxy<T>
      extended by org.pfsw.reflect.NumericFieldProxy<T>
All Implemented Interfaces:
IValueHolder<T>
Direct Known Subclasses:
BigDecimalFieldProxy, IntegerFieldProxy, LongFieldProxy

public abstract class NumericFieldProxy<T>
extends FieldProxy<T>

Provides an abstract field proxy for numeric types which offers some extra convenience methods for basic calculation.


Constructor Summary
protected NumericFieldProxy(java.lang.Object owner, java.lang.reflect.Field field)
           
protected NumericFieldProxy(java.lang.Object owner, java.lang.String fieldName)
           
 
Method Summary
abstract  T add(T value)
          Adds the given value to this field's value and returns the result.
protected  T changeToValue(T value)
           
 T dec()
          Decrements this field's value by 1, stores the result in the field and returns it.
abstract  T divide(T value)
          Divides this field's value by the given value, stores the result in the field and returns the result.
 T inc()
          Increments this field's value by 1, stores the result in the field and returns it.
abstract  T multiply(T value)
          Multiplies this field's value with the given value, stores the result in the field and returns the result.
protected abstract  T negate(T value)
          Returns the negated value of the given value.
protected abstract  T one()
          Returns the representation of 1 as type T.
 T subtract(T value)
          Subtracts the given value from this field's value, stores the result in the field and returns it.
 
Methods inherited from class org.pfsw.reflect.FieldProxy
get, getField, getOwner, isNull, isPresent, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericFieldProxy

protected NumericFieldProxy(java.lang.Object owner,
                            java.lang.reflect.Field field)

NumericFieldProxy

protected NumericFieldProxy(java.lang.Object owner,
                            java.lang.String fieldName)
Method Detail

inc

public T inc()
Increments this field's value by 1, stores the result in the field and returns it.


dec

public T dec()
Decrements this field's value by 1, stores the result in the field and returns it.


subtract

public T subtract(T value)
Subtracts the given value from this field's value, stores the result in the field and returns it.


add

public abstract T add(T value)
Adds the given value to this field's value and returns the result.


multiply

public abstract T multiply(T value)
Multiplies this field's value with the given value, stores the result in the field and returns the result.


divide

public abstract T divide(T value)
Divides this field's value by the given value, stores the result in the field and returns the result.


negate

protected abstract T negate(T value)
Returns the negated value of the given value.


one

protected abstract T one()
Returns the representation of 1 as type T.


changeToValue

protected T changeToValue(T value)