Class TypeUtils


  • public final class TypeUtils
    extends Object

    Convenience methods for creating type information

    Author:
    David B. Bracewell
    • Method Detail

      • asClass

        public static <T> Class<T> asClass​(Type type)
        Converts type information to class information
        Type Parameters:
        T - the type parameter
        Parameters:
        type - the type
        Returns:
        the class
      • getActualTypeArguments

        public static Type[] getActualTypeArguments​(Type type)
        Get actual type arguments type [ ].
        Parameters:
        type - the type
        Returns:
        the type [ ]
      • getOrObject

        public static Type getOrObject​(int n,
                                       Type... types)
        Gets or object.
        Parameters:
        n - the n
        types - the types
        Returns:
        the or object
      • isArray

        public static boolean isArray​(Type type)
        Is array boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • isAssignable

        public static boolean isAssignable​(Type parent,
                                           Type child)
        Is assignable boolean.
        Parameters:
        parent - the t 1
        child - the to check
        Returns:
        the boolean
      • isCollection

        public static boolean isCollection​(Type type)
        Is collection boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • isContainer

        public static boolean isContainer​(Type type)
        Is container boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • isIterable

        public static boolean isIterable​(Type type)
        Is iterable boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • isIterator

        public static boolean isIterator​(Type type)
        Is iterator boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • isPrimitive

        public static boolean isPrimitive​(Type type)
        Is primitive boolean.
        Parameters:
        type - the type
        Returns:
        the boolean
      • parameterizedType

        public static Type parameterizedType​(Type rawType,
                                             Type... typeArguments)
        Creates parameterized type information for the given raw type and optional type arguments.
        Parameters:
        rawType - the raw type
        typeArguments - the type arguments
        Returns:
        the parameterized type
      • parse

        public static Type parse​(String s)
        From string type.
        Parameters:
        s - the s
        Returns:
        the type