jTransfo, 0.10

org.jtransfo.internal
Class AccessorSyntheticField

java.lang.Object
  extended by org.jtransfo.internal.AccessorSyntheticField
All Implemented Interfaces:
SyntheticField

public class AccessorSyntheticField
extends Object
implements SyntheticField

Abstraction of a Field which uses the getter and setter if they exist.


Constructor Summary
AccessorSyntheticField(ReflectionHelper reflectionHelper, Class<?> clazz, Field field)
          Constructor, access field using getter and setter if exist.
AccessorSyntheticField(ReflectionHelper reflectionHelper, Class<?> clazz, String name, boolean readOnlyField)
          Constructor, there is no field, just use getter (and setter is not readOnly).
 
Method Summary
 Object get(Object object)
          Get field value.
 String getName()
          Get field name.
 Class<?> getType()
          Get field type.
 void set(Object object, Object value)
          Set field value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessorSyntheticField

public AccessorSyntheticField(ReflectionHelper reflectionHelper,
                              Class<?> clazz,
                              Field field)
Constructor, access field using getter and setter if exist.

Parameters:
reflectionHelper - reflection helper to use
clazz - clazz of which the field is part
field - field (may be in a parent class of clazz)

AccessorSyntheticField

public AccessorSyntheticField(ReflectionHelper reflectionHelper,
                              Class<?> clazz,
                              String name,
                              boolean readOnlyField)
                       throws JTransfoException
Constructor, there is no field, just use getter (and setter is not readOnly).

Parameters:
reflectionHelper - reflection helper to use
clazz - clazz of which the field is part
name - field name
readOnlyField - is a getter sufficient
Throws:
JTransfoException - can not find getter for given name or
Method Detail

get

public Object get(Object object)
           throws IllegalAccessException,
                  IllegalArgumentException
Get field value.

Specified by:
get in interface SyntheticField
Parameters:
object - object which contains the field.
Returns:
field value
Throws:
IllegalAccessException - illegal access
IllegalArgumentException - illegal argument

set

public void set(Object object,
                Object value)
         throws IllegalAccessException,
                IllegalArgumentException
Set field value.

Specified by:
set in interface SyntheticField
Parameters:
object - object which contains the field.
value - field value
Throws:
IllegalAccessException - illegal access
IllegalArgumentException - illegal argument

getName

public String getName()
Get field name.

Specified by:
getName in interface SyntheticField
Returns:
field name

getType

public Class<?> getType()
Get field type.

Specified by:
getType in interface SyntheticField
Returns:
field type

jTransfo, 0.10

Copyright © 2013. All rights reserved.