public List<Field> getAnnotatedFields(Class<? extends Annotation> klass) { return Reflections.getAnnotatedFieldsForClassHierarchy(object.getClass(), klass); }
private List<Field> getBindableModelFields() { List<Field> allModelFields = Reflections.getFieldsOfTypeForClassHierarchy(object.getClass(), BindableModel.class); List<Field> notBindableFields = Reflections.getAnnotatedFieldsForClassHierarchy(object.getClass(), NotBindable.class); allModelFields = ImmutableList.copyOf(Iterables.filter(allModelFields, Predicates.not(Predicates.in(notBindableFields)))); List<Field> nonFinalModelFields = ImmutableList.copyOf(Iterables.filter(allModelFields, Predicates.not(Reflections.IS_FIELD_FINAL))); if (!nonFinalModelFields.isEmpty()) { throw new BindingException("All BindableModels have to be final or marked with @NotBindable, but "+ Iterables.transform(nonFinalModelFields, Reflections.FIELD_TO_NAME)+" are not."); } return allModelFields; }