|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.annovalidator.util.ReflectionUtil
public class ReflectionUtil
Utility class for performing common reflection operations with more sensible error handling.
Constructor Summary | |
---|---|
ReflectionUtil()
|
Method Summary | |
---|---|
static java.lang.reflect.Method |
determineAnnotationParameterMethod(java.lang.annotation.Annotation annotation,
java.lang.String parameterName)
Determines the Method on annotation that
matches parameterName . |
static java.lang.Class<?> |
determineAnnotationParameterType(java.lang.annotation.Annotation annotation,
java.lang.String parameterName)
Determines the type of a parameter (implemented as a Method )
on an Annotation . |
static java.lang.Object |
determineAnnotationParameterValue(java.lang.annotation.Annotation annotation,
java.lang.String parameterName)
Determines the value of a particular parameter in an Annotation . |
static java.lang.Object |
determineFieldValue(java.lang.Object object,
java.lang.reflect.Field field)
Determines the value of field in object . |
static java.lang.Object |
determineFieldValue(java.lang.Object object,
java.lang.String fieldName)
Returns the value of the Field named fieldName
on object . |
static java.lang.annotation.Annotation |
getAnnotation(java.lang.reflect.Field field,
java.lang.Class annotationClass)
|
static java.lang.reflect.Field |
getField(java.lang.Object object,
java.lang.String fieldName)
Returns the Field on object that matches
fieldName . |
static boolean |
isAnnotationParameterPresent(java.lang.annotation.Annotation annotation,
java.lang.String parameterName)
Determines whether annotation has a parameter named
parameterName . |
static boolean |
isAnnotationPresent(java.lang.Class<?> objectClass,
java.lang.Class<ValidationStep> annotationType)
Determines whether objectClass is annotated with
annotationType . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectionUtil()
Method Detail |
---|
public static java.lang.reflect.Method determineAnnotationParameterMethod(java.lang.annotation.Annotation annotation, java.lang.String parameterName)
Method
on annotation
that
matches parameterName
.
annotation
- The Annotation
to examine.parameterName
- The name of the Method
to find.
Method
on annotation
whose name
matches parameterName
.
ValidatorAnnotationException
- If parameterName
cannot be accessed or does not
exist in annotation
.public static java.lang.Object determineAnnotationParameterValue(java.lang.annotation.Annotation annotation, java.lang.String parameterName)
Annotation
.
annotation
- The Annotation
to inspect.parameterName
- The name of the parameter to fetch.
parameterName
parameter in
annotation
.
ValidatorAnnotationException
- If parameterName
cannot be accessed or does not
exist in annotation
.public static java.lang.Class<?> determineAnnotationParameterType(java.lang.annotation.Annotation annotation, java.lang.String parameterName)
Method
)
on an Annotation
.
annotation
- The Annotation
containing the parameter.parameterName
- The name of the parameter whose type needs to be determined.
parameterName
in annotation
.public static java.lang.Object determineFieldValue(java.lang.Object object, java.lang.reflect.Field field)
field
in object
.
object
- The Object
that contains field
.field
- The Field
that we want to know the value of.
field
.
ValidatorFieldException
- If field
cannot be read.public static java.lang.Object determineFieldValue(java.lang.Object object, java.lang.String fieldName)
Field
named fieldName
on object
.
object
- The Object
containing the Field
.fieldName
- The name of the Field
.
Field
named fieldName
on object
.public static java.lang.reflect.Field getField(java.lang.Object object, java.lang.String fieldName)
Field
on object
that matches
fieldName
.
object
- The object that contains the field.fieldName
- The name of the field to return.
Field
matching fieldName
from
object
.public static boolean isAnnotationParameterPresent(java.lang.annotation.Annotation annotation, java.lang.String parameterName)
annotation
has a parameter named
parameterName
.
annotation
- The Annotation
to examine.parameterName
- The name of the parameter to check for.
true
if annotation
has a parameter
named parameterName
, otherwise false
.public static boolean isAnnotationPresent(java.lang.Class<?> objectClass, java.lang.Class<ValidationStep> annotationType)
objectClass
is annotated with
annotationType
. Behaves the same was as
Class.isAnnotationPresent(Class)
, but checks declared
annotations as well as non-declared.
objectClass
- The class to check for an Annotation
.annotationType
- The Class
of the Annotation
to
check for.
true
if an Annotation
of type
annotationClass
is found on
objectClass
, otherwise false
.public static java.lang.annotation.Annotation getAnnotation(java.lang.reflect.Field field, java.lang.Class annotationClass)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |