Class Types

java.lang.Object
org.jboss.weld.util.Types

public class Types extends Object
Utility class for Types
Author:
Pete Muir
  • Field Details

    • TYPE_TO_CLASS_FUNCTION

      public static final Function<Type,Class<?>> TYPE_TO_CLASS_FUNCTION
  • Method Details

    • boxedType

      public static Type boxedType(Type type)
      Gets the boxed type of a class
      Parameters:
      type - The type
      Returns:
      The boxed type
    • boxedClass

      public static Class<?> boxedClass(Class<?> type)
    • getTypeId

      public static String getTypeId(Type type)
    • getCanonicalType

      public static Type getCanonicalType(Class<?> clazz)
      Returns a canonical type for a given class. If the class is a raw type of a parameterized class, the matching ParameterizedType (with unresolved type variables) is resolved. If the class is an array then the component type of the array is canonicalized Otherwise, the class is returned.
      Returns:
    • getCanonicalType

      public static Type getCanonicalType(Type type)
      Parameters:
      type -
      Returns:
    • containsTypeVariable

      public static boolean containsTypeVariable(Type type)
    • getRawTypes

      public static Set<Class<?>> getRawTypes(Set<Type> types)
    • getRawTypes

      public static Class<?>[] getRawTypes(Type[] types)
    • buildClassNameMap

      public static <C extends Class<?>> Map<String,C> buildClassNameMap(Iterable<C> set)
      Builds (class name -> class) map for given classes.
    • isActualType

      public static boolean isActualType(Type type)
      Determines whether the given type is an actual type. A type is considered actual if it is a raw type, a parameterized type or an array type.
      Parameters:
      type - the given type
      Returns:
      true if and only if the given type is an actual type
    • isArray

      public static boolean isArray(Type type)
      Determines whether the given type is an array type.
      Parameters:
      type - the given type
      Returns:
      true if the given type is a subclass of java.lang.Class or implements GenericArrayType
    • getArrayComponentType

      public static Type getArrayComponentType(Type type)
      Determines the component type for a given array type.
      Parameters:
      type - the given array type
      Returns:
      the component type of a given array type
    • isArrayOfUnboundedTypeVariablesOrObjects

      public static boolean isArrayOfUnboundedTypeVariablesOrObjects(Type[] types)
      Determines whether the given array only contains unbounded type variables or Object.class.
      Parameters:
      types - the given array of types
      Returns:
      true if and only if the given array only contains unbounded type variables or Object.class
    • isRawGenericType

      public static boolean isRawGenericType(Type type)
    • isIllegalBeanType

      public static boolean isIllegalBeanType(Type beanType)
      Parameters:
      beanType -
      Returns:
      true if the given type is not a legal bean type, false otherwise
    • isMoreSpecific

      public static boolean isMoreSpecific(Type type1, Type type2)
      Parameters:
      type1 -
      type2 -
      Returns:
      true if the first type is more specific than the second type (is a subtype of), false otherwise