Class CovariantTypes


  • public class CovariantTypes
    extends Object
    Utility class that captures standard covariant Java assignability rules. This class operates on all the possible Type subtypes: Class, ParameterizedType, TypeVariable, WildcardType, GenericArrayType. To make this class easier to understand and maintain, there is a separate isAssignableFrom method for each combination of possible types. Each of these methods compares two type instances and determines whether the first one is assignable from the other. TypeVariables are considered a specific unknown type restricted by the upper bound. No inference of type variables is performed.
    Author:
    Jozef Hartinger
    • Method Detail

      • isAssignableFromAtLeastOne

        public static boolean isAssignableFromAtLeastOne​(Type type1,
                                                         Type[] types2)
      • isAssignableFrom

        public static boolean isAssignableFrom​(Type type1,
                                               Type type2)