Search in sources :

Example 1 with MemberResolver

use of com.fasterxml.classmate.MemberResolver 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);
}
Also used : ResolvedMethod(com.fasterxml.classmate.members.ResolvedMethod) TypeResolver(com.fasterxml.classmate.TypeResolver) AnnotationConfiguration(com.fasterxml.classmate.AnnotationConfiguration) MemberResolver(com.fasterxml.classmate.MemberResolver) ResolvedTypeWithMembers(com.fasterxml.classmate.ResolvedTypeWithMembers)

Example 2 with MemberResolver

use of com.fasterxml.classmate.MemberResolver in project chassis by Kixeye.

the class CustomAccessorsProvider method constructorsIn.

/**
 * Finds the constructors in the given type
 *
 * @param resolvedType the type to search
 */
public com.google.common.collect.ImmutableList<ResolvedConstructor> constructorsIn(ResolvedType resolvedType) {
    MemberResolver resolver = new MemberResolver(typeResolver);
    resolver.setIncludeLangObject(false);
    if (resolvedType.getErasedType() == Object.class) {
        return ImmutableList.of();
    }
    ResolvedTypeWithMembers typeWithMembers = resolver.resolve(resolvedType, null, null);
    return FluentIterable.from(newArrayList(typeWithMembers.getConstructors())).toList();
}
Also used : MemberResolver(com.fasterxml.classmate.MemberResolver) ResolvedTypeWithMembers(com.fasterxml.classmate.ResolvedTypeWithMembers)

Aggregations

MemberResolver (com.fasterxml.classmate.MemberResolver)2 ResolvedTypeWithMembers (com.fasterxml.classmate.ResolvedTypeWithMembers)2 AnnotationConfiguration (com.fasterxml.classmate.AnnotationConfiguration)1 TypeResolver (com.fasterxml.classmate.TypeResolver)1 ResolvedMethod (com.fasterxml.classmate.members.ResolvedMethod)1