Class TypeHelper
- java.lang.Object
-
- org.hibernate.validator.internal.util.TypeHelper
-
public final class TypeHelper extends Object
Provides utility methods for working with types.- Author:
- Mark Hobson, Hardy Ferentschik
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TypeextractConstraintType(Class<? extends ConstraintValidator<?,?>> validator)static TypeextractConstraintValidatorTypeArgumentType(Class<? extends ConstraintValidator<?,?>> validator, int typeArgumentIndex)static TypeextractValidatedType(Class<? extends ConstraintValidator<?,?>> validator)static GenericArrayTypegenericArrayType(Type componentType)Creates a generic array type for the specified component type.static TypegetComponentType(Type type)static Class<?>getErasedReferenceType(Type type)static TypegetErasedType(Type type)Gets the erased type of the specified type.static <A extends Annotation>
Map<Type,ConstraintValidatorDescriptor<A>>getValidatorTypes(Class<A> annotationType, List<ConstraintValidatorDescriptor<A>> validators)static booleanisArray(Type type)static booleanisAssignable(Type supertype, Type type)static booleanisHibernateValidatorEnhancedBean(Class<?> clazz)static booleanisInstance(Type type, Object object)static booleanisUnboundWildcard(Type type)static ParameterizedTypeparameterizedType(Class<?> rawType, Type... actualTypeArguments)Creates a parameterized type for the specified raw type and actual type arguments.
-
-
-
Method Detail
-
isHibernateValidatorEnhancedBean
public static boolean isHibernateValidatorEnhancedBean(Class<?> clazz)
-
getErasedType
public static Type getErasedType(Type type)
Gets the erased type of the specified type.- Parameters:
type- the type to perform erasure on- Returns:
- the erased type, never a parameterized type nor a type variable
- See Also:
- 4.6 Type Erasure
-
isArray
public static boolean isArray(Type type)
-
genericArrayType
public static GenericArrayType genericArrayType(Type componentType)
Creates a generic array type for the specified component type.- Parameters:
componentType- the component type- Returns:
- the generic array type
-
parameterizedType
public static ParameterizedType parameterizedType(Class<?> rawType, Type... actualTypeArguments)
Creates a parameterized type for the specified raw type and actual type arguments.- Parameters:
rawType- the raw typeactualTypeArguments- the actual type arguments- Returns:
- the parameterized type
- Throws:
MalformedParameterizedTypeException- if the number of actual type arguments differs from those defined on the raw type
-
getValidatorTypes
public static <A extends Annotation> Map<Type,ConstraintValidatorDescriptor<A>> getValidatorTypes(Class<A> annotationType, List<ConstraintValidatorDescriptor<A>> validators)
- Type Parameters:
A- the type of the annotation- Parameters:
annotationType- The annotation type.validators- List of constraint validator classes (for a given constraint).- Returns:
- Return a Map<Class, Class<? extends ConstraintValidator>> where the map key is the type the validator accepts and value the validator class itself.
-
extractValidatedType
public static Type extractValidatedType(Class<? extends ConstraintValidator<?,?>> validator)
-
extractConstraintType
public static Type extractConstraintType(Class<? extends ConstraintValidator<?,?>> validator)
-
extractConstraintValidatorTypeArgumentType
public static Type extractConstraintValidatorTypeArgumentType(Class<? extends ConstraintValidator<?,?>> validator, int typeArgumentIndex)
-
isUnboundWildcard
public static boolean isUnboundWildcard(Type type)
-
-