@Test public void getAllFieldsOfClassTest() throws Exception { List<Field> allFieldsOfClassInstances; allFieldsOfClassInstances = ReflectionUtils.getAllFieldsOfClass(B.class,true, false); assertEquals(fieldsToSortedFieldNames(allFieldsOfClassInstances),Arrays.asList("a","s", "x", "y", "z")); allFieldsOfClassInstances = ReflectionUtils.getAllFieldsOfClass(B.class,false, true); assertEquals(fieldsToSortedFieldNames(allFieldsOfClassInstances),Arrays.asList("a", "x", "y", "z")); }
public static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible) { List<Field> fields = new LinkedList<>(); appendFieldsOfClassInstances_aux(clazz, includeStaticFields, fields); if (setAccessible) fields.forEach(f->f.setAccessible(true)); return fields; }
ReflectionUtils { public static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible) { List<Field> fields = new LinkedList<>(); appendFieldsOfClassInstances_aux(clazz, includeStaticFields, fields); if (setAccessible) fields.forEach(f->f.setAccessible(true)); return fields; } }
ReflectionUtils { public static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible) { List<Field> fields = new LinkedList<>(); appendFieldsOfClassInstances_aux(clazz, includeStaticFields, fields); if (setAccessible) fields.forEach(f->f.setAccessible(true)); return fields; }  }
ReflectionUtils { public static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible) { List<Field> fields = new LinkedList<>(); appendFieldsOfClassInstances_aux(clazz, includeStaticFields, fields); if (setAccessible) fields.forEach(f->f.setAccessible(true)); return fields; }  static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible); static Object getValueOfFieldSettingAccessible(Field field, Object obj); static List<Method> getAllMethodsOfClass(Class<?> clazz, boolean setAccessible); static Class<?> getClassByName(String name); }
ReflectionUtils { public static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible) { List<Field> fields = new LinkedList<>(); appendFieldsOfClassInstances_aux(clazz, includeStaticFields, fields); if (setAccessible) fields.forEach(f->f.setAccessible(true)); return fields; }  static List<Field> getAllFieldsOfClass(Class<?> clazz, boolean includeStaticFields, boolean setAccessible); static Object getValueOfFieldSettingAccessible(Field field, Object obj); static List<Method> getAllMethodsOfClass(Class<?> clazz, boolean setAccessible); static Class<?> getClassByName(String name);  }