public static Type getUpperBound ( Type type , Types types ) { if ( type . hasTag ( TypeTag . WILDCARD ) ) { return types . wildUpperBound ( type ) ; } if ( type . hasTag ( TypeTag . TYPEVAR ) && ( ( TypeVar ) type ) . isCaptured ( ) ) { return types . cvarUpperBound ( type ) ; } if ( type . getUpperBound ( ) != null ) { return type . getUpperBound ( ) ; } // concrete type, e.g. java.lang.String, or a case we haven't considered return type ; }
Returns the upper bound of a type if it has one or the type itself if not . Correctly handles wildcards and capture variables .