use of java.lang.reflect.AnnotatedElement in project motech by motech.
the class RestIgnoreProcessor method getElementsToProcess.
@Override
protected Set<? extends AnnotatedElement> getElementsToProcess() {
List<Member> members = ReflectionsUtil.getFilteredMembers(clazz, restIgnore());
Set<AnnotatedElement> elements = new LinkedHashSet<>(members.size());
for (Member member : members) {
if (member instanceof AnnotatedElement) {
elements.add((AnnotatedElement) member);
}
}
return elements;
}
use of java.lang.reflect.AnnotatedElement in project motech by motech.
the class FieldProcessorTest method shouldNotProcessIgnoredSettersAndGetters.
@Test
public void shouldNotProcessIgnoredSettersAndGetters() {
Method setIgnoredField = getAccessibleMethod(Sample.class, "setIgnoredPrivate", String.class);
Method getIgnoredField = getAccessibleMethod(Sample.class, "getIgnoredPrivate", new Class[0]);
processor.process(setIgnoredField);
processor.process(getIgnoredField);
verify(schemaHolder, times(2)).getType(String.class);
Collection<FieldDto> setterFields = processor.getElements();
assertEquals(1, setterFields.size());
List<AnnotatedElement> actual = new ArrayList<>();
actual.addAll(processor.getElementsToProcess());
assertEquals(Sample.FIELD_COUNT, actual.size());
assertFalse(actual.contains(getIgnoredField));
assertFalse(actual.contains(setIgnoredField));
}
use of java.lang.reflect.AnnotatedElement in project motech by motech.
the class AbstractProcessor method execute.
/**
* {@inheritDoc}
* <p/>
* Developer have to specify what actions have to be done before and after processing each
* found element.
*/
@Override
public void execute(Bundle bundle, SchemaHolder schemaHolder) {
this.bundle = bundle;
this.schemaHolder = schemaHolder;
Class<A> annotation = getAnnotationType();
Set<? extends AnnotatedElement> elements = getElementsToProcess();
beforeExecution();
for (AnnotatedElement element : elements) {
LOGGER.debug("Processing: Annotation: {} Object: {}", annotation.getName(), element);
try {
process(element);
} catch (RuntimeException e) {
LOGGER.error("An error occurred while processing annotated element in Bundle: {}, in Element: {} because of:", bundle.getSymbolicName(), element, e);
}
LOGGER.debug("Processed: Annotation: {} Object: {}", annotation.getName(), element);
}
afterExecution();
}
use of java.lang.reflect.AnnotatedElement in project motech by motech.
the class NonEditableProcessor method getElementsToProcess.
@Override
protected Set<? extends AnnotatedElement> getElementsToProcess() {
List<Member> members = ReflectionsUtil.getFilteredMembers(clazz, nonEditable());
Set<AnnotatedElement> elements = new LinkedHashSet<>(members.size());
for (Member member : members) {
if (member instanceof AnnotatedElement) {
elements.add((AnnotatedElement) member);
}
}
return elements;
}
use of java.lang.reflect.AnnotatedElement in project motech by motech.
the class UIDisplayableProcessor method getElementsToProcess.
@Override
protected Set<? extends AnnotatedElement> getElementsToProcess() {
List<Member> members = ReflectionsUtil.getFilteredMembers(clazz, uiDisplayable());
Set<AnnotatedElement> elements = new LinkedHashSet<>(members.size());
for (Member member : members) {
if (member instanceof AnnotatedElement) {
elements.add((AnnotatedElement) member);
}
}
return elements;
}
Aggregations