Java Reflection Field Find findField(Object propertyId, Class classOfItem)

Here you can find the source of findField(Object propertyId, Class classOfItem)

Description

find Field

License

Open Source License

Declaration

public static Field findField(Object propertyId, Class classOfItem) 

Method Source Code

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

import java.lang.reflect.Field;

public class Main {
    public static Field findField(Object propertyId, Class classOfItem) {
        Field declaredField;/*from   w  w  w. ja  v a 2  s. c  o m*/
        try {
            declaredField = classOfItem.getDeclaredField(String.valueOf(propertyId));
        } catch (NoSuchFieldException e) {
            declaredField = null;
        }
        if (declaredField == null && !Object.class.equals(classOfItem))
            return findField(propertyId, classOfItem.getSuperclass());
        return declaredField;
    }
}

Related

  1. findField(Object obj, String fieldName)
  2. findField(Object obj, String fieldName, Class type)
  3. findField(Object obj, String name)
  4. findField(Object object, String fieldName)
  5. findField(Object object, String name, Class klass)
  6. findField(Object target, Class type)
  7. findField(Object target, String fieldName)
  8. findField(String fieldName, ArrayList fields)
  9. findField(String fieldName, Class cl)