FasterXML / java-classmate

Library for introspecting generic type information of types, member/static methods, fields. Especially useful for POJO/Bean introspection.
http://fasterxml.com
Apache License 2.0
258 stars 42 forks source link

Add a method that checks if a given Type is a super-type of another #31

Open kaqqao opened 8 years ago

kaqqao commented 8 years ago

When dealing with Types and not Classes, it's rather hard to tell if a given type is a super- (or sub-) type of another, as there is no equivalent to Class#isAssignableFrom. GentyRef has a method for this, GenericTypeReflector.isSuperType(superType, subType), but that lib is rather outdated and seems unmaintained, and it generally doesn't make sense to add another type resolution lib.

cowtowncoder commented 8 years ago

@kaqqao Sounds reasonable, just need to figure out where to put that in an API, and whether to do "same or supertype" or strict "is supertype", as well as combinations (maybe allow Class<?> argument and resolved one).

cowtowncoder commented 11 months ago

I do not remember the background here, but it would seem to me that this relationship could be relatively easily be determined by comparing "raw classes" of two types, no? (this wouldn't verify generic type compatibility but should otherwise work fine)