BeanUtils { public static List<AnnotatedElement> getFieldsAndAccessors(Class<?> clazz) { List<AnnotatedElement> properties = new ArrayList<>(); properties.addAll(Arrays.stream(clazz.getDeclaredFields()).filter(f -> !f.isSynthetic()).collect(Collectors.toList())); try { Arrays.asList(Introspector.getBeanInfo(clazz, Object.class).getPropertyDescriptors()).forEach(prop -> { if (prop.getReadMethod() != null) { properties.add(prop.getReadMethod()); } if (prop.getWriteMethod() != null) { properties.add(prop.getWriteMethod()); } }); } catch (IntrospectionException ex) { throw new IllegalArgumentException(String.format("Could not parse properties from class %s", clazz), ex); } return properties; } private  BeanUtils(); static List<AnnotatedElement> getFieldsAndAccessors(Class<?> clazz);  }
@Test public void shouldFindFieldsAndAccessors() { List<AnnotatedElement> fieldsAndAccessors = BeanUtils.getFieldsAndAccessors(SomeBean.class); assertThat(fieldsAndAccessors.size(), is(3)); fieldsAndAccessors.forEach(fieldsAndAccessor -> assertThat(fieldsAndAccessor.toString().toLowerCase(), containsString("foo")) ); }