@Test public void testGetField_01() { Field f = ReflectionUtil.getField(Person.class, "name"); assertNotNull("01", f); }
public static Field getField(Class<?> cls, String name) { while (cls != null) { for (Field f : cls.getDeclaredFields()) { if (f.getName().equals(name)) return f; } cls = cls.getSuperclass(); } return null; }
ReflectionUtil { public static Field getField(Class<?> cls, String name) { while (cls != null) { for (Field f : cls.getDeclaredFields()) { if (f.getName().equals(name)) return f; } cls = cls.getSuperclass(); } return null; } }
ReflectionUtil { public static Field getField(Class<?> cls, String name) { while (cls != null) { for (Field f : cls.getDeclaredFields()) { if (f.getName().equals(name)) return f; } cls = cls.getSuperclass(); } return null; } private  ReflectionUtil(); }
ReflectionUtil { public static Field getField(Class<?> cls, String name) { while (cls != null) { for (Field f : cls.getDeclaredFields()) { if (f.getName().equals(name)) return f; } cls = cls.getSuperclass(); } return null; } private  ReflectionUtil(); static T newInstance(Class<T> cls); static T newInstance(Class<T> cls, Object... args); static T newInstance(Class<T> cls, Class<?>[] paramTypes, Object... args); static void set(Object obj, String field, Object value); static void setStatic(Class<?> cls, String field, Object value); @SuppressWarnings("unchecked") static T get(Object obj, String field); @SuppressWarnings("unchecked") static T getStatic(Class<?> cls, String field); @SuppressWarnings("unchecked") static T call(Object obj, String method); static T call(Object obj, String method, Object... args); @SuppressWarnings("unchecked") static T call(Object obj, String method, Class<?>[] paramTypes, Object... args); @SuppressWarnings("unchecked") static T callStatic(Class<?> cls, String method); static T callStatic(Class<?> cls, String method, Object... args); @SuppressWarnings("unchecked") static T callStatic(Class<?> cls, String method, Class<?>[] paramTypes,
      Object... args); static Field getField(Class<?> cls, String name); static Method getMethod(Class<?> cls, String name, Class<?>... parameterTypes); }
ReflectionUtil { public static Field getField(Class<?> cls, String name) { while (cls != null) { for (Field f : cls.getDeclaredFields()) { if (f.getName().equals(name)) return f; } cls = cls.getSuperclass(); } return null; } private  ReflectionUtil(); static T newInstance(Class<T> cls); static T newInstance(Class<T> cls, Object... args); static T newInstance(Class<T> cls, Class<?>[] paramTypes, Object... args); static void set(Object obj, String field, Object value); static void setStatic(Class<?> cls, String field, Object value); @SuppressWarnings("unchecked") static T get(Object obj, String field); @SuppressWarnings("unchecked") static T getStatic(Class<?> cls, String field); @SuppressWarnings("unchecked") static T call(Object obj, String method); static T call(Object obj, String method, Object... args); @SuppressWarnings("unchecked") static T call(Object obj, String method, Class<?>[] paramTypes, Object... args); @SuppressWarnings("unchecked") static T callStatic(Class<?> cls, String method); static T callStatic(Class<?> cls, String method, Object... args); @SuppressWarnings("unchecked") static T callStatic(Class<?> cls, String method, Class<?>[] paramTypes,
      Object... args); static Field getField(Class<?> cls, String name); static Method getMethod(Class<?> cls, String name, Class<?>... parameterTypes);  }