public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {
PersistentProperty<?> property = association.getInverse();
ResourceMapping mapping = propertyMappings.getMappingFor(property);
DescriptorBuilder builder = descriptor().//
name(mapping.getRel()).doc(getDocFor(mapping.getDescription()));
if (associationLinks.isLinkableAssociation(property)) {
ResourceMetadata targetTypeMapping = mappings.getMappingFor(property.getActualType());
String localPath = targetTypeMapping.getRel().concat("#").concat(targetTypeMapping.getItemResourceRel());
Link link = ControllerLinkBuilder.linkTo(AlpsController.class).slash(localPath).withSelfRel();
builder.//
type(Type.SAFE).//
rt(link.getHref());
} else {
List<Descriptor> nestedDescriptors = buildPropertyDescriptors(property.getActualType(), baseRel.concat(".")
.concat(mapping.getRel()));
builder = builder.//
type(Type.SEMANTIC).//
descriptors(nestedDescriptors);
}
propertyDescriptors.add(builder.build());
}
});
return propertyDescriptors;
}