org.sormula.reflect
Class SormulaField<C,T>

java.lang.Object
  extended by org.sormula.reflect.SormulaField<C,T>
Type Parameters:
C - class containing the field
T - class of field

public class SormulaField<C,T>
extends java.lang.Object

A field within a class with additional methods needed by sormula for reflection.

Author:
Jeff Miller

Constructor Summary
SormulaField(java.lang.reflect.Field field)
          Constructs for a field.
 
Method Summary
 java.lang.String getCanonicalGetMethodName()
          Gets cannonical "get" method name.
 java.lang.String getCanonicalSetMethodName()
          Gets cannonical "set" method name.
 java.lang.reflect.Field getField()
          Gets field supplied in constructor.
 T invokeGetMethod(C object)
          Gets value from get method of an object using reflection.
 void invokeSetMethod(C object, T value)
          Sets value on object with set method using reflection.
 boolean isArray()
          Gets field array type.
 boolean isBooleanMethod()
          Reports boolean return type of field.
 boolean isClass(java.lang.Class<?> c)
          Tests if field is instance of class.
 boolean isCollection()
          Gets field Collection inheritance.
 boolean isMap()
          Gets field Map inheritance.
 boolean isScalar()
          Reports if field is scalar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SormulaField

public SormulaField(java.lang.reflect.Field field)
             throws ReflectException
Constructs for a field.

Parameters:
field - java reflection Field that corresponds to class variable
Throws:
ReflectException - if error
Method Detail

getField

public java.lang.reflect.Field getField()
Gets field supplied in constructor.

Returns:
field Java field

isArray

public boolean isArray()
Gets field array type.

Returns:
if field is an array
Since:
1.9 and 2.3

isCollection

public boolean isCollection()
Gets field Collection inheritance.

Returns:
true if field is a collection
Since:
1.9 and 2.3

isMap

public boolean isMap()
Gets field Map inheritance.

Returns:
true if field is a Map
Since:
1.9 and 2.3

isBooleanMethod

public boolean isBooleanMethod()
Reports boolean return type of field.

Returns:
true if field type is primative boolean

invokeGetMethod

public T invokeGetMethod(C object)
                  throws ReflectException
Gets value from get method of an object using reflection.

Parameters:
object - object to invoke get method upon
Returns:
return value of get method invoked upon object
Throws:
ReflectException - if error

invokeSetMethod

public void invokeSetMethod(C object,
                            T value)
                     throws ReflectException
Sets value on object with set method using reflection.

Parameters:
object - object to invoke set method upon
value - value to set
Throws:
ReflectException - if error

isScalar

public boolean isScalar()
Reports if field is scalar.

Returns:
true if field is not a Collection and not a Map
See Also:
isClass(Class)

isClass

public boolean isClass(java.lang.Class<?> c)
Tests if field is instance of class.

Parameters:
c - class to test
Returns:
true if field is instance of c or subclass of c
See Also:
Class.isAssignableFrom(Class)

getCanonicalGetMethodName

public java.lang.String getCanonicalGetMethodName()
Gets cannonical "get" method name.

Returns:
package-name.class-name#get-method-name

getCanonicalSetMethodName

public java.lang.String getCanonicalSetMethodName()
Gets cannonical "set" method name.

Returns:
package-name.class-name#set-method-name