RelationTypeMetadata<RelationMetadata> relationMetadata = (RelationTypeMetadata) relationTypeMetadata;
Direction relationDirection = getRelationDirection(annotatedType, propertyMethod, relationTypeMetadata, relationMetadata);
methodMetadata = new RelationCollectionPropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection,
metadataFactory.createCollectionPropertyMetadata(propertyMethod));
} else {
throw new XOException("Unsupported type argument '" + typeArgument.getName() + "' for collection property: " + propertyType.getName());
}
} else if (annotatedMethods.containsKey(propertyType)) {
AnnotatedType referencedType = new AnnotatedType(propertyType);
Direction relationDirection;
RelationTypeMetadata<RelationMetadata> relationMetadata;
if (isEntityType(referencedType)) {
relationDirection = getRelationDirection(propertyMethod, Direction.FROM);
com.buschmais.xo.spi.reflection.AnnotatedElement<?> relationElement = getRelationDefinitionElement(propertyMethod);
relationMetadata = new RelationTypeMetadata<>(metadataFactory.createRelationMetadata(relationElement, metadataByType));
methodMetadata = new EntityReferencePropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection, metadataFactory.createReferencePropertyMetadata(propertyMethod));
} else if (isRelationType(referencedType)) {
TypeMetadata relationTypeMetadata = getOrCreateTypeMetadata(propertyType);
relationMetadata = (RelationTypeMetadata) relationTypeMetadata;
relationDirection = getRelationDirection(annotatedType, propertyMethod, relationTypeMetadata, relationMetadata);
methodMetadata = new RelationReferencePropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection, metadataFactory.createReferencePropertyMetadata(propertyMethod));
} else {
throw new XOException("Unsupported type for reference property: " + propertyType.getName());
}
} else {
methodMetadata = new PrimitivePropertyMethodMetadata<>(propertyMethod, metadataFactory.createPropertyMetadata(propertyMethod));
}
return methodMetadata;