// If the method is not defined in ResourceInfo, we handle it below
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
Link link;
if ((link = method.getAnnotation(Link.class)) != null) {
switch (link.method()) {
case GET:
if (List.class.isAssignableFrom(method.getReturnType())) {
//noinspection unchecked
return new HalLinkList(halResource, link.relation(),
getCollectionType(method.getGenericReturnType(), 0, ResourceInfo.class),
halClient);
} else if (Map.class.isAssignableFrom(method.getReturnType())) {
//noinspection unchecked
return new HalLinkMap(halResource, link.relation(), link.keyField(),
getCollectionType(method.getGenericReturnType(), 1, ResourceInfo.class),
halClient);
} else {
return halClient.getResource(halResource, method.getReturnType(),
getRelationHref(link, args, method.getParameterAnnotations()), false);
}
case POST:
if (args == null) {
throw new IllegalArgumentException("POST operations require a representation argument.");
}
return halClient.postResource(method.getReturnType(),
getRelationHref(link, args, method.getParameterAnnotations()), args[0]);
case PUT:
if (args == null) {
throw new IllegalArgumentException("PUT operations require a representation argument.");
}
return halClient.putResource(method.getReturnType(),
getRelationHref(link, args, method.getParameterAnnotations()), args[0]);
case DELETE:
return halClient.deleteResource(method.getReturnType(),
getRelationHref(link, args, method.getParameterAnnotations()));
default:
throw new UnsupportedOperationException("Unexpected HTTP method: " + link.method());
}
} else if (method.getName().startsWith("get")) {
return convert(method.getGenericReturnType(), halResource.getProperty(getPropertyName(method.getName())));
} else if (method.getName().equals("toString") && args == null) {