Class Types


  • public class Types
    extends Object
    Factory methods for types.
    • Method Detail

      • arrayOf

        public static Type arrayOf​(Type elementType)
        Returns an array type whose elements are all instances of componentType.
      • listOf

        public static Type listOf​(Type elementType)
        Returns a Type that is a List of the given element type.
      • setOf

        public static Type setOf​(Type elementType)
        Returns a Type that is a Set of the given element type.
      • streamOf

        public static Type streamOf​(Type elementType)
        Returns a Type that is a Stream of the given element type.
      • mapOf

        public static Type mapOf​(Type valueElementType)
        Return the Type for a Map with String keys and the given value element type.
        Parameters:
        valueElementType - The type of the values in the Map.
        Returns:
        Type for a Map with String keys and the given value element type.
      • newParameterizedType

        public static ParameterizedType newParameterizedType​(Type rawType,
                                                             Type... typeArguments)
        Returns a new parameterized type, applying typeArguments to rawType. Use this method if rawType is not enclosed in another type.
      • rawType

        public static Class<?> rawType​(Type type)
        Return the raw type for the given potentially generic type.
      • typeArguments

        public static Type[] typeArguments​(Type type)
        Return the generic type arguments expecting type to be a ParameterizedType.