Java Reflection Field Find findField(Class clazz, String name)

Here you can find the source of findField(Class clazz, String name)

Description

find Field

License

Open Source License

Declaration

private static Field findField(Class<?> clazz, String name) 

Method Source Code

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

import java.lang.reflect.Field;

public class Main {
    private static Field findField(Class<?> clazz, String name) {
        Class<?> searchType = clazz;
        while (!Object.class.equals(searchType) && searchType != null) {
            Field[] fields = searchType.getDeclaredFields();
            for (Field field : fields) {
                if ((name == null || name.equals(field.getName()))) {
                    return field;
                }//from  www.j a  v  a  2  s  .c  o m
            }
            searchType = searchType.getSuperclass();
        }
        return null;
    }
}

Related

  1. findField(Class clazz, String name)
  2. findField(Class clazz, String name)
  3. findField(Class clazz, String name)
  4. findField(Class clazz, String name)
  5. findField(Class clazz, String name)
  6. findField(Class clazz, String propName)
  7. findField(Class clazz, String targetName, Class targetType, boolean checkInheritance, boolean strictType)
  8. findField(Class cls, String fieldName)
  9. findField(Class cls, String fieldName)