ReflectUtil { public static List<String> flattenProperties(final Object target, final Class<?> clazz) { return flattenPropeties(target, clazz, "class"); }  static Pair<Class<?>, Field> getAnyField(Class<?> clazz, String fieldName); static Set<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotation, String[] packageNames); static boolean isCmdClassAsync(Class<?> cmdClass, Class<?>[] searchClasses); static List<Field> getAllFieldsForClass(Class<?> cmdClass, Class<?> baseClass); static Set<Field> getAllFieldsForClass(Class<?> cmdClass, Class<?>[] excludeClasses); static List<String> flattenProperties(final Object target, final Class<?> clazz); static List<String> flattenPropeties(final Object target, final Class<?> clazz, final String... excludedProperties); static String getEntityName(Class clz);  }
@Test public void testFlattenNonNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "foo"); final Bean bean = new Bean(1, true, "foo"); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }
@Test public void testFlattenNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "null"); final Bean bean = new Bean(1, true, null); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }
@Test public void testFlattenPropertiesNullTarget() throws Exception { assertEquals(emptyList(), flattenProperties(null, Bean.class)); }