Java Reflection Field Find findFieldRecursively(Class c, String fieldName)

Here you can find the source of findFieldRecursively(Class c, String fieldName)

Description

find Field Recursively

License

Apache License

Declaration

private static Field findFieldRecursively(Class<?> c, String fieldName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;

public class Main {
    private static Field findFieldRecursively(Class<?> c, String fieldName) {
        Field f = null;//from w  w w .  j a  va2 s. com
        try {
            f = c.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            if (!c.equals(Object.class))
                f = findFieldRecursively(c.getSuperclass(), fieldName);
        }
        return f;
    }
}

Related

  1. findFieldInClassHierarchy(Class clazz, String fieldName)
  2. findFieldIncludeSuperclass(String fieldName, Class clazz)
  3. findFieldInternal(Class currentClass, Class annotation, Set fields)
  4. findFieldOfBean(Object bean, String fieldName)
  5. findFieldOfTypeInClass(final Class source, final Class type)
  6. findFields(Class c, boolean allowTransient, int max, Iterable> fieldClassesToFind, Iterable> exceptClasses)
  7. findFields(Class type)
  8. findFields(final Class clazz, final Predicate filter)
  9. findFieldsAnnotatedWith(Class annotation, Class parentClass)