Java Reflection Field Find findField(Class claz, String... names)

Here you can find the source of findField(Class claz, String... names)

Description

find Field

License

LGPL

Declaration

public static Field findField(Class<?> claz, String... names) 

Method Source Code

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

import java.lang.reflect.Field;

public class Main {
    public static Field findField(Class<?> claz, String... names) {
        Exception e = null;//from   www.  j a  v a 2 s .co m
        Class<?> clas = claz;
        while (claz != null) {
            for (String name : names) {
                try {
                    return clas.getDeclaredField(name);
                } catch (Exception ee) {
                    e = ee;
                }
            }
            clas = claz.getSuperclass();
        }
        throw new IllegalArgumentException(e);
    }
}

Related

  1. findField(Class type, String fieldName)
  2. findField(Class c, String name)
  3. findField(Class c, String property, Class propertyType)
  4. findField(Class cl, String fieldName)
  5. findField(Class classToCheck, String propertyName)
  6. findField(Class clazz, final String field)
  7. findField(Class clazz, String field)
  8. findField(Class clazz, String field, Class type, int index)
  9. findField(Class clazz, String fieldName)