use of com.fasterxml.classmate.ResolvedTypeWithMembers in project hibernate-orm by hibernate.
the class AttributeConverterDescriptorImpl method resolveMember.
private ResolvedMember resolveMember(XProperty xProperty, MetadataBuildingContext buildingContext) {
final ClassmateContext classmateContext = buildingContext.getMetadataCollector().getClassmateContext();
final ReflectionManager reflectionManager = buildingContext.getBuildingOptions().getReflectionManager();
final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve(reflectionManager.toClass(xProperty.getDeclaringClass()));
final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve(declaringClassType, null, null);
final Member member = toMember(xProperty);
if (member instanceof Method) {
for (ResolvedMethod resolvedMember : declaringClassWithMembers.getMemberMethods()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else if (member instanceof Field) {
for (ResolvedField resolvedMember : declaringClassWithMembers.getMemberFields()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else {
throw new HibernateException("Unexpected java.lang.reflect.Member type from org.hibernate.annotations.common.reflection.java.JavaXMember : " + member);
}
throw new HibernateException("Could not locate resolved type information for attribute [" + member.getName() + "] from Classmate");
}
use of com.fasterxml.classmate.ResolvedTypeWithMembers in project hibernate-orm by hibernate.
the class AutoApplicableConverterDescriptorStandardImpl method resolveMember.
private ResolvedMember resolveMember(XProperty xProperty, MetadataBuildingContext buildingContext) {
final ClassmateContext classmateContext = buildingContext.getBootstrapContext().getClassmateContext();
final ReflectionManager reflectionManager = buildingContext.getBootstrapContext().getReflectionManager();
final ResolvedType declaringClassType = classmateContext.getTypeResolver().resolve(reflectionManager.toClass(xProperty.getDeclaringClass()));
final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve(declaringClassType, null, null);
final Member member = toMember(xProperty);
if (member instanceof Method) {
for (ResolvedMethod resolvedMember : declaringClassWithMembers.getMemberMethods()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else if (member instanceof Field) {
for (ResolvedField resolvedMember : declaringClassWithMembers.getMemberFields()) {
if (resolvedMember.getName().equals(member.getName())) {
return resolvedMember;
}
}
} else {
throw new HibernateException("Unexpected java.lang.reflect.Member type from org.hibernate.annotations.common.reflection.java.JavaXMember : " + member);
}
throw new HibernateException("Could not locate resolved type information for attribute [" + member.getName() + "] from Classmate");
}
use of com.fasterxml.classmate.ResolvedTypeWithMembers 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.ResolvedTypeWithMembers 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();
}
use of com.fasterxml.classmate.ResolvedTypeWithMembers 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