Consider
Response.ok(new GenericEntity<List<Bean>>(Arrays.<Bean>asList(new Bean("a"), new Bean("b"))) {}).build();
It is clear from the Response.ok() javadoc that the "actual
entity" is a List<> and not a GenericEntity<>.
Presumably, then, Response.getEntity(), which, according to the
javadoc, returns "the message entity Java instance", should return
the List<>.
I don't think this is true. IMO there is nothing in the API docs that forces an implementation to "unpack" the actual entity wrapped by GenericEntity. The API docs of ok() just state:
It is the callers responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required.
I just had a quick look at the Jersey implementation of ResponseBuilder.entity(Object) and Jersey doesn't seem to perform any unpacking of GenericEntity here.
So IMO Response.getEntity() should return the original GenericEntity which also allows the caller to get all the generic type information.
Any other thoughts?
Christian