I'm using Spring's RestTemplate
to make calls against a REST web service. One of these calls is to return a list of objects of a certain type. The RestTemplate
methods require that a class argument be supplied to indicate the expected return type.
// restTemplate is type org.springframework.web.client.RestTemplate
URI restServiceURI = new URI("http://example.com/foo")
restTemplate.getForObject(restServiceURI, List<Foo>.class);
Obviously, this doesn't compile. You cannot get a static .class
property when you supply the type argument like that. The code compiles when I remove the type argument, but that generates a rawtypes
compiler warning.
My question is simple. Am I stuck with suppressing the compiler warning or is there a cleaner way to code for this?