• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Type of a List in java  RSS feed

 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 143
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I'm doing some robospice stuff in android and got strucked in class type retrival



i also tried following to use instead for Response and there was no luck because Response doesn't have a public constructor


Any help would be greatly appriciated!

Thanks!
-supun
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a Class object for a generic type. There is only Response.class for the raw Response type. However, you can still do what you want with a little bit of cheating:

You can't cast Response.class directly to a Class<Response<RESULT>>, but the intermediate cast solves that.
 
Supun Lakshan Dissanayake
Ranch Hand
Posts: 143
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:There is no such thing as a Class object for a generic type. There is only Response.class for the raw Response type. However, you can still do what you want with a little bit of cheating:

You can't cast Response.class directly to a Class<Response<RESULT>>, but the intermediate cast solves that.[/quote

Thank you very much Rob!
You're life saver
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!