use of org.freud.analysed.javasource.Annotation in project freud by LMAX-Exchange.
the class JavaSourceJdom method parseAnnotations.
//////////////////////////////////////////////////////////////////////////////////////////////////
public static List<Annotation> parseAnnotations(final Element element) {
final List<Annotation> annotations;
JXPathContext context = JXPathContext.newContext(element);
List annotationList = context.selectNodes("/" + JavaSourceTokenType.MODIFIER_LIST.getName() + "/" + JavaSourceTokenType.AT.getName());
annotations = new ArrayList<Annotation>(annotationList.size());
for (Object annotationElement : annotationList) {
annotations.add(new AnnotationJdom((Element) annotationElement));
}
return annotations;
}
use of org.freud.analysed.javasource.Annotation 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