use of com.fasterxml.classmate.AnnotationConfiguration in project dropwizard by dropwizard.
the class SelfValidatingValidatorTest method getMethod.
private ResolvedMethod getMethod(String name, Class<?>... params) {
AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration.StdConfiguration(AnnotationInclusion.INCLUDE_AND_INHERIT_IF_INHERITED);
TypeResolver typeResolver = new TypeResolver();
MemberResolver memberResolver = new MemberResolver(typeResolver);
ResolvedTypeWithMembers annotatedType = memberResolver.resolve(typeResolver.resolve(InvalidExample.class), annotationConfiguration, null);
for (ResolvedMethod m : annotatedType.getMemberMethods()) {
if (hasSignature(m, name, params)) {
return m;
}
}
throw new IllegalStateException("Could not resolve method " + name + Arrays.toString(params) + " in " + InvalidExample.class);
}
use of com.fasterxml.classmate.AnnotationConfiguration in project dropwizard by dropwizard.
the class SelfValidatingValidator method findMethods.
/**
* This method generates <code>ValidationCaller</code>s for each method annotated
* with <code>@SelfValidation</code> that adheres to required signature.
*/
@SuppressWarnings({ "rawtypes" })
private <T> List<ValidationCaller> findMethods(Class<T> annotated) {
ResolvedTypeWithMembers annotatedType = memberResolver.resolve(typeResolver.resolve(annotated), annotationConfiguration, null);
final List<ValidationCaller> callers = Arrays.stream(annotatedType.getMemberMethods()).filter(this::isValidationMethod).filter(this::isMethodCorrect).map(m -> new ProxyValidationCaller<>(annotated, m)).collect(Collectors.toList());
if (callers.isEmpty()) {
log.warn("The class {} is annotated with @SelfValidating but contains no valid methods that are annotated " + "with @SelfValidation", annotated);
}
return callers;
}
Aggregations