FasterXML/java-classmate

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

kaqqao opened this issue · 4 comments

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.

@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).

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)

I somehow only now see this 😶
I'm pretty sure this was specifically about generic type compatibility. But I've since forked GenTyRef (GeantyRef) and am using that now for my advanced reflection needs. So feel free to close this unless you like the idea of adding such a feature to classmate.

Will do. May be re-opened if others find it useful and (ideally) submit a patch. :)