Class TypeChecker

java.lang.Object
org.glassfish.hk2.utilities.reflection.TypeChecker

public class TypeChecker extends Object
This class contains various utilities for ensuring java type safety
  • Constructor Details

    • TypeChecker

      public TypeChecker()
  • Method Details

    • isRawTypeSafe

      public static boolean isRawTypeSafe(Type requiredType, Type beanType)
      Returns true if the given requiredType is safely assignable from the given beanType. In otherwords, if requiredType = beanType without any cast. It should be noted that this checker is using the CDI rules (as stated in CDI version 1.1 in section
      Parameters:
      requiredType - The type being assigned into
      beanType - the type being assigned
      Returns:
      true if things are type safe
    • isTypeVariableTypeVariableSafe

      private static boolean isTypeVariableTypeVariableSafe(TypeVariable<?> rtv, TypeVariable<?> btv)
    • isActualTypeVariableSafe

      private static boolean isActualTypeVariableSafe(Class<?> actual, TypeVariable<?> tv)
    • isWildcardTypeVariableSafe

      private static boolean isWildcardTypeVariableSafe(WildcardType wildcard, TypeVariable<?> tv)
    • getBound

      private static Class<?> getBound(Type[] bounds)
    • isWildcardActualSafe

      private static boolean isWildcardActualSafe(WildcardType wildcard, Class<?> actual)
    • getWildcard

      private static WildcardType getWildcard(Type type)
    • getTypeVariable

      private static TypeVariable<?> getTypeVariable(Type type)
    • isWildcard

      private static boolean isWildcard(Type type)
    • isTypeVariable

      private static boolean isTypeVariable(Type type)
    • isActualType

      private static boolean isActualType(Type type)
      An actual type is either a Class or a ParameterizedType
      Parameters:
      type - The type to test
      Returns:
      true if this is an actual type
    • isArrayType

      private static boolean isArrayType(Type type)
      An array type can be a class that is an array or a GenericArrayType
      Parameters:
      type - The type to test
      Returns:
      true if this is an actual type
    • getArrayType

      private static Type getArrayType(Type type)
      An array type can be a class that is an array or a GenericArrayType
      Parameters:
      type - The type to test
      Returns:
      true if this is an actual type