use of com.fasterxml.classmate.members.ResolvedMember in project hibernate-orm by hibernate.
the class AttributeConverterDescriptorImpl method shouldAutoApplyToCollectionElement.
@Override
public boolean shouldAutoApplyToCollectionElement(XProperty xProperty, MetadataBuildingContext context) {
if (!autoApply) {
return false;
}
final ResolvedMember collectionMember = resolveMember(xProperty, context);
final ResolvedType elementType;
if (Map.class.isAssignableFrom(collectionMember.getType().getErasedType())) {
elementType = collectionMember.getType().typeParametersFor(Map.class).get(1);
} else if (Collection.class.isAssignableFrom(collectionMember.getType().getErasedType())) {
elementType = collectionMember.getType().typeParametersFor(Collection.class).get(0);
} else {
throw new HibernateException("Attribute was neither a Collection nor a Map : " + collectionMember.getType().getErasedType());
}
return typesMatch(domainType, elementType);
}
use of com.fasterxml.classmate.members.ResolvedMember in project hibernate-orm by hibernate.
the class AttributeConverterDescriptorImpl method shouldAutoApplyToMapKey.
@Override
public boolean shouldAutoApplyToMapKey(XProperty xProperty, MetadataBuildingContext context) {
if (!autoApply) {
return false;
}
final ResolvedMember collectionMember = resolveMember(xProperty, context);
final ResolvedType keyType;
if (Map.class.isAssignableFrom(collectionMember.getType().getErasedType())) {
keyType = collectionMember.getType().typeParametersFor(Map.class).get(0);
} else {
throw new HibernateException("Attribute was not a Map : " + collectionMember.getType().getErasedType());
}
return typesMatch(domainType, keyType);
}
use of com.fasterxml.classmate.members.ResolvedMember 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");
}
Aggregations