public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
PersistentEntity<?, ?> entity = entities.getPersistentEntity(targetType.getType());
if (entity == null) {
throw new ConversionFailedException(sourceType, targetType, source, new IllegalArgumentException(
"No PersistentEntity information available for " + targetType.getType()));
}
URI uri = (URI) source;
String[] parts = uri.getPath().split("/");
if (parts.length < 2) {
throw new ConversionFailedException(sourceType, targetType, source, new IllegalArgumentException(
"Cannot resolve URI " + uri + ". Is it local or remote? Only local URIs are resolvable."));
}
return domainClassConverter.convert(parts[parts.length - 1], STRING_TYPE, targetType);
}