Java Utililty Methods Reflection Field Find

List of utility methods to do Reflection Field Find

Description

The list of methods to do Reflection Field Find are organized into topic(s).

Method

ClassfindFieldType(Field field, Class concreteClass)
Tries to discover type of given field If the field ha a concrete type then there is nothing to do and it's type is returned.
if (field.getGenericType() instanceof Class) {
    return field.getType();
TypeVariable[] typeParameters = field.getDeclaringClass().getTypeParameters();
for (int i = 0; i < typeParameters.length; i++) {
    if (typeParameters[i].getName().equals(field.getGenericType().getTypeName())) {
        ParameterizedType genericSuperclass = findMatchingSuperclass(concreteClass, field);
        if (genericSuperclass != null) {
...
FieldfindFieldWithAnnotation(String fieldName, Class clazz, Class annotationType)
Look for a field based on his name and a given Annotation in a class.
Field field = getField(fieldName, clazz);
if (field != null && field.isAnnotationPresent(annotationType)) {
    return field;
return null;