org.clazzes.util.reflect
Interface FieldAccessor

All Known Implementing Classes:
POJOFieldAccessor

public interface FieldAccessor

This interface is implemented by all classes, that allow access to fileds of an object.

Author:
wglas

Method Summary
 boolean checkMandatory()
          Parse all relevant Annotations and try to retrieve a Column -Annotation and test it's nullable() value.
 boolean checkUpdatable()
          Parse all relevant Annotations and try to retrieve a Column -Annotation and test it's updatable() value.
<T extends java.lang.annotation.Annotation>
T
getAnnotation(java.lang.Class<T> type)
           
 java.lang.annotation.Annotation[] getAnnotations()
           
 java.lang.Class getDeclaringClass()
           
 FieldAccessor getIdAccessor()
          Get the accessor used to access the ID-Field of the same POJO this FieldAccessor belongs to.
 java.lang.String getName()
           
 java.lang.Class getType()
           
 java.lang.Object getValueOf(java.lang.Object pojo)
          Gets the associated field value of the given instance of the underlying class.
 void setIdAccessor(FieldAccessor idAccessor)
          Set the accessor used to access the ID-Field of the same POJO this FieldAccessor belongs to.
 void setValueOn(java.lang.Object pojo, java.lang.Object value)
          Sets the associated field value on the given instance of the underlying class.
 

Method Detail

getType

java.lang.Class getType()
Returns:
The type of the field or property accessed.

getDeclaringClass

java.lang.Class getDeclaringClass()
Returns:
The class which contains the field or property accessed.

getAnnotation

<T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> type)
Parameters:
type - The annotation type to request for.
Returns:
The annotation of the given field or property getter of the given type or null, if no such annotation exists.

getAnnotations

java.lang.annotation.Annotation[] getAnnotations()
Returns:
All annotations of the given field or property getter or null, if no annotations exists.

getName

java.lang.String getName()
Returns:
The name of the field or property accessed.

getValueOf

java.lang.Object getValueOf(java.lang.Object pojo)
                            throws java.lang.IllegalArgumentException,
                                   java.lang.IllegalAccessException,
                                   java.lang.reflect.InvocationTargetException
Gets the associated field value of the given instance of the underlying class.

Parameters:
pojo - The object of which to get the field value.
Returns:
The value of the associated field.
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

setValueOn

void setValueOn(java.lang.Object pojo,
                java.lang.Object value)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalAccessException,
                       java.lang.reflect.InvocationTargetException
Sets the associated field value on the given instance of the underlying class.

Parameters:
pojo - The object on which to set the field value.
value - The value of the associated field.
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

checkMandatory

boolean checkMandatory()
Parse all relevant Annotations and try to retrieve a Column -Annotation and test it's nullable() value.

Returns:
true for primitives,
(!Column.nullable()) if a Column -Annotation could be found,
false otherwise.

checkUpdatable

boolean checkUpdatable()
Parse all relevant Annotations and try to retrieve a Column -Annotation and test it's updatable() value.

Returns:
true for primitives,
Column.updatable() if a Column -Annotation could be found,
true otherwise.

setIdAccessor

void setIdAccessor(FieldAccessor idAccessor)
Set the accessor used to access the ID-Field of the same POJO this FieldAccessor belongs to.

Parameters:
idAccessor - The FieldAccessor for the ID-Field.

getIdAccessor

FieldAccessor getIdAccessor()
Get the accessor used to access the ID-Field of the same POJO this FieldAccessor belongs to.

Returns:
The FieldAccessor for the ID-Field (may be null).


Copyright © 2010. All Rights Reserved.