org.pfsw.reflect
Class FieldProxy<T>

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

public class FieldProxy<T>
extends java.lang.Object
implements IValueHolder<T>

A proxy for a specific field in a target object that allows getting and setting to that field via reflection, regardless of the field's visibility (except if a SecurityManager is active).


Constructor Summary
FieldProxy(java.lang.Object owner, java.lang.reflect.Field field)
           
FieldProxy(java.lang.Object owner, java.lang.String fieldName)
           
 
Method Summary
 T get()
          Returns the current value (might be null).
protected  java.lang.reflect.Field getField()
           
protected  java.lang.Object getOwner()
           
 boolean isNull()
          Returns whether or not the underlying value is null.
 boolean isPresent()
          Returns whether or not the underlying value is not null.
 void set(T value)
          Sets the current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldProxy

public FieldProxy(java.lang.Object owner,
                  java.lang.reflect.Field field)

FieldProxy

public FieldProxy(java.lang.Object owner,
                  java.lang.String fieldName)
Method Detail

get

public T get()
Returns the current value (might be null).

Specified by:
get in interface IValueHolder<T>

set

public void set(T value)
Sets the current value.

Specified by:
set in interface IValueHolder<T>
Parameters:
value - The new value (might be null).

isNull

public boolean isNull()
Returns whether or not the underlying value is null.

Specified by:
isNull in interface IValueHolder<T>

isPresent

public boolean isPresent()
Returns whether or not the underlying value is not null.

Specified by:
isPresent in interface IValueHolder<T>

getOwner

protected java.lang.Object getOwner()

getField

protected java.lang.reflect.Field getField()