Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the T class in generic Class<T> assignable from another class?

Edit Since there were many downvotes and people who didn't understand what I'm asking for, I'll rephrase:

How do I find out at runtime what is the class that foo was generified from?

public boolean doesClassImplementList(Class<?> genericClass)
{
  // help me fill this in
  // this method should return true if genericClass implements List
  // I can't do this because it doesn't compile:
  return genericClass instanceof List;
}
like image 373
ripper234 Avatar asked Mar 01 '23 13:03

ripper234


1 Answers

Class.isAssignableFrom

like image 177
Tom Hawtin - tackline Avatar answered May 11 '23 08:05

Tom Hawtin - tackline