Saturday, August 10, 2013

using generic types in response entities with jersey 2.0 client

a special type for a special case

Java Generics are great, but they can truly be a beast to deal with once you start dealing with Class references that can't carry a generic type with them. In the case of using Jersey 2.0's client API, you may come into a situation where a resource returns a generified type, such as List<Message>. You can't map the entity to List<Message>.class, but thankfully Jersey has a very easy way to handle this case:

That's it! Just binding it to GenericType<List<Message>>(){} takes care of it!

Source: http://jersey.576304.n2.nabble.com/How-can-I-parse-a-java-util-List-lt-gt-Is-it-supported-by-the-Jersey-client-td2300852.html

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. an excellent first teddy choice for your baby is Blanket teddy bear. Blanket teddy bears are small fleece blankets that have a teddy bear attached from the arms up. Famous teddy bears

    ReplyDelete
  3. All about the inner bear - what materials are used to make our favourite cuddly friends? This article takes a look at both today's teddies and those of bygone days. Famous teddy bears

    ReplyDelete