org.hibernate.validator.internal.util

## 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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static GenericArrayType` | `genericArrayType(Type componentType)` Creates a generic array type for the specified component type.
    `static Type` | `getComponentType(Type type)`
    `static Type` | `getErasedType(Type type)` Gets the erased type of the specified type.
    `static <A extends Annotation> Map<Type,Class<? extends ConstraintValidator<A,?>>>` | `getValidatorsTypes(Class<A> annotationType, List<Class<? extends ConstraintValidator<A,?>>> validators)`
    `static boolean` | `isArray(Type type)`
    `static boolean` | `isAssignable(Type supertype, Type type)`
    `static boolean` | `isInstance(Type type, Object object)`
    `static ParameterizedType` | `parameterizedType(Class<?> rawType, Type... actualTypeArguments)` Creates a parameterized type for the specified raw type and actual type arguments.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isAssignable

          public static boolean isAssignable(Type supertype,
                             Type type)

    - #### 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)

    - #### getComponentType

          public static Type getComponentType(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

    - #### isInstance

          public static boolean isInstance(Type type,
                           Object object)

    - #### 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 type
        `actualTypeArguments` - 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

    - #### getValidatorsTypes

          public static <A extends Annotation> Map<Type,Class<? extends ConstraintValidator<A,?>>> getValidatorsTypes(Class<A> annotationType,
                                                                                                      List<Class<? extends ConstraintValidator<A,?>>> validators)

      Parameters:
        `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.

Copyright © 2007-2014 Red Hat, Inc. All Rights Reserved