Java Reflection Field Find findField(final Class currentClass, final String fieldName)

Here you can find the source of findField(final Class currentClass, final String fieldName)

Description

find Field

License

Apache License

Declaration

static Field findField(final Class<?> currentClass, final String fieldName) 

Method Source Code


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

import java.lang.reflect.Field;

public class Main {
    static Field findField(final Class<?> currentClass, final String fieldName) {

        if (null == currentClass) {
            return null;
        }// ww w .  ja v a  2s  .  c  o m
        for (final Field cf : currentClass.getDeclaredFields()) {
            if (fieldName.equals(cf.getName())) {
                return cf;
            }
        }
        return findField(currentClass.getSuperclass(), fieldName);
    }
}

Related

  1. findField(final Class aClass, final String fieldName)
  2. findField(final Class clazz, final String name)
  3. findField(final Class clazz, final String name)
  4. findField(final Class clazz, final String name, final Class type)
  5. findField(final Class cls, final String fieldName)
  6. findField(final Class declaringClass, final String fieldName)
  7. findField(final Class klaz, final String fieldName)
  8. findField(final Object instance, final String name)
  9. findField(final Object src, final String fieldName)