use of org.freud.analysed.javasource.AnnotatedElementDeclaration in project freud by LMAX-Exchange.
the class AnnotatedElementDeclarationMatchers method hasDeclaredAnnotation.
public FreudExtendedMatcher<T> hasDeclaredAnnotation(final String annotationName, final Matcher<String> defaultValueMatcher) {
return new FreudExtendedMatcher<T>() {
@Override
protected boolean matchesSafely(final AnnotatedElementDeclaration toBeAnalysed) {
for (Annotation declaredAnnotation : toBeAnalysed.getDeclaredAnnotations()) {
if (annotationName.equals(declaredAnnotation.getName())) {
return defaultValueMatcher.matches(declaredAnnotation.getDefaultParameter());
}
}
return false;
}
@Override
public String toString() {
Description description = new StringDescription();
description.appendText("HasDeclaredAnnotation(").appendText(annotationName);
defaultValueMatcher.describeTo(description);
description.appendText(")");
return description.toString();
}
@Override
public void describeTo(Description description) {
description.appendText(toString());
}
};
}
Aggregations