Java Reflection Field Find findField(Class clazz, String field, Class type, int index)

Here you can find the source of findField(Class clazz, String field, Class type, int index)

Description

find Field

License

Open Source License

Declaration

public static Field findField(Class<?> clazz, String field, Class<?> type, int index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Field;

public class Main {
    public static Field findField(Class<?> clazz, String field, Class<?> type, int index) {
        int temp = index;
        for (Field f : clazz.getDeclaredFields())
            if ((field == null || f.getName().equals(field)) && type.isAssignableFrom(f.getType()) && temp-- <= 0)
                return f;
        if (clazz.getSuperclass() != null)
            return findField(clazz.getSuperclass(), field, type, index);
        return null;
    }/*from  www. ja  v a2 s.co  m*/
}

Related

  1. findField(Class cl, String fieldName)
  2. findField(Class classToCheck, String propertyName)
  3. findField(Class claz, String... names)
  4. findField(Class clazz, final String field)
  5. findField(Class clazz, String field)
  6. findField(Class clazz, String fieldName)
  7. findField(Class clazz, String fieldName)
  8. findField(Class clazz, String fieldName)
  9. findField(Class clazz, String fieldName)