Class TypeChecker
java.lang.Object
org.glassfish.hk2.utilities.reflection.TypeChecker
This class contains various utilities for ensuring
java type safety
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Type
getArrayType
(Type type) An array type can be a class that is an array or a GenericArrayTypeprivate static Class
<?> private static TypeVariable
<?> getTypeVariable
(Type type) private static WildcardType
getWildcard
(Type type) private static boolean
isActualType
(Type type) An actual type is either a Class or a ParameterizedTypeprivate static boolean
isActualTypeVariableSafe
(Class<?> actual, TypeVariable<?> tv) private static boolean
isArrayType
(Type type) An array type can be a class that is an array or a GenericArrayTypestatic boolean
isRawTypeSafe
(Type requiredType, Type beanType) Returns true if the given requiredType is safely assignable from the given beanType.private static boolean
isTypeVariable
(Type type) private static boolean
isTypeVariableTypeVariableSafe
(TypeVariable<?> rtv, TypeVariable<?> btv) private static boolean
isWildcard
(Type type) private static boolean
isWildcardActualSafe
(WildcardType wildcard, Class<?> actual) private static boolean
isWildcardTypeVariableSafe
(WildcardType wildcard, TypeVariable<?> tv)
-
Constructor Details
-
TypeChecker
public TypeChecker()
-
-
Method Details
-
isRawTypeSafe
Returns true if the given requiredType is safely assignable from the given beanType. In otherwords, ifrequiredType = 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 intobeanType
- the type being assigned- Returns:
- true if things are type safe
-
isTypeVariableTypeVariableSafe
-
isActualTypeVariableSafe
-
isWildcardTypeVariableSafe
-
getBound
-
isWildcardActualSafe
-
getWildcard
-
getTypeVariable
-
isWildcard
-
isTypeVariable
-
isActualType
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
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
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
-