Top Description Constructors Methods
org.glassfish.hk2.utilities.reflection

public Class TypeChecker

extends Object
Class Inheritance
Imports
java.lang.reflect.GenericArrayType, .ParameterizedType, .Type, .TypeVariable, .WildcardType

This class contains various utilities for ensuring java type safety
Author
jwells

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Type

Returns:

true if this is an actual type
getArrayType
(Type
The type to test
type
)

An array type can be a class that is an array or a GenericArrayType

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

private static TypeVariable<?>
private static WildcardType
private static boolean

Returns:

true if this is an actual type
isActualType
(Type
The type to test
type
)

An actual type is either a Class or a ParameterizedType

private static boolean
private static boolean

Returns:

true if this is an actual type
isArrayType
(Type
The type to test
type
)

An array type can be a class that is an array or a GenericArrayType

public static boolean

Returns:

true if things are type safe
isRawTypeSafe
(Type
The type being assigned into
requiredType
,
Type
the type being assigned
beanType
)

Returns true if the given requiredType is safely assignable from the given beanType.

private static boolean
private static boolean
private static boolean
private static boolean
private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TypeCheckerback to summary
public TypeChecker()

Method Detail

getArrayTypeback to summary
private static Type getArrayType(Type type)

An array type can be a class that is an array or a GenericArrayType

Parameters
type:Type

The type to test

Returns:Type

true if this is an actual type

getBoundback to summary
private static Class<?> getBound(Type[] bounds)
getTypeVariableback to summary
private static TypeVariable<?> getTypeVariable(Type type)
getWildcardback to summary
private static WildcardType getWildcard(Type type)
isActualTypeback to summary
private static boolean isActualType(Type type)

An actual type is either a Class or a ParameterizedType

Parameters
type:Type

The type to test

Returns:boolean

true if this is an actual type

isActualTypeVariableSafeback to summary
private static boolean isActualTypeVariableSafe(Class<?> actual, TypeVariable<?> tv)
isArrayTypeback to summary
private static boolean isArrayType(Type type)

An array type can be a class that is an array or a GenericArrayType

Parameters
type:Type

The type to test

Returns:boolean

true if this is an actual type

isRawTypeSafeback to summary
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:Type

The type being assigned into

beanType:Type

the type being assigned

Returns:boolean

true if things are type safe

isTypeVariableback to summary
private static boolean isTypeVariable(Type type)
isTypeVariableTypeVariableSafeback to summary
private static boolean isTypeVariableTypeVariableSafe(TypeVariable<?> rtv, TypeVariable<?> btv)
isWildcardback to summary
private static boolean isWildcard(Type type)
isWildcardActualSafeback to summary
private static boolean isWildcardActualSafe(WildcardType wildcard, Class<?> actual)
isWildcardTypeVariableSafeback to summary
private static boolean isWildcardTypeVariableSafe(WildcardType wildcard, TypeVariable<?> tv)