Class DefaultType


  • public final class DefaultType
    extends Object
    Constant implementations of the Type interface that can be used to reference standard java types. If a modifying method is called on any of these objects, the model will be copied before performing the operation. This makes sure the original state of the constant is never changed.
    Author:
    Emil Forslund
    • Field Detail

      • WILDCARD

        public static final Type WILDCARD
    • Method Detail

      • genericType

        public static Type genericType​(Type type,
                                       Type... typeParameters)
        Returns a new SimpleParameterizedType with the specified type parameters.
        Parameters:
        type - the base type
        typeParameters - all its type parameters
        Returns:
        the new generic type
        Since:
        2.5
      • genericType

        public static Type genericType​(Type type,
                                       String... typeParameters)
        Returns a new SimpleParameterizedType with the specified type parameters.
        Parameters:
        type - the base type
        typeParameters - all its type parameters
        Returns:
        the new generic type
        Since:
        2.5
      • classOf

        public static Type classOf​(Type innerType)
        Generates a Type to represent a java standard Class with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • list

        public static Type list​(Type innerType)
        Generates a Type to represent a java standard List with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • set

        public static Type set​(Type innerType)
        Generates a Type to represent a java standard Set with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • map

        public static Type map​(Type innerTypeA,
                               Type innerTypeB)
        Generates a Type to represent a java standard Map with generic type variables.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        Returns:
        the resulting type
      • queue

        public static Type queue​(Type innerType)
        Generates a Type to represent a java standard Queue with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • stack

        public static Type stack​(Type innerType)
        Generates a Type to represent a java standard Stack with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • optional

        public static Type optional​(Type innerType)
        Generates a Type to represent a java standard Optional with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • entry

        public static Type entry​(Type innerTypeA,
                                 Type innerTypeB)
        Generates a Type to represent a java standard Entry with generic type variables.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        Returns:
        the resulting type
      • function

        public static Type function​(Type innerTypeA,
                                    Type innerTypeB)
        Generates a Type to represent a java standard Function with generic type variables.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        Returns:
        the resulting type
      • bifunction

        public static Type bifunction​(Type innerTypeA,
                                      Type innerTypeB,
                                      Type innerTypeC)
        Generates a Type to represent a java standard BiFunction with generic type variables.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        innerTypeC - the third type variable
        Returns:
        the resulting type
        Since:
        2.5
      • intFunction

        public static Type intFunction​(Type innerType)
        Generates a Type to represent a java standard IntFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • longFunction

        public static Type longFunction​(Type innerType)
        Generates a Type to represent a java standard LongFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • doubleFunction

        public static Type doubleFunction​(Type innerType)
        Generates a Type to represent a java standard DoubleFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • toIntFunction

        public static Type toIntFunction​(Type innerType)
        Generates a Type to represent a java standard ToIntFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • toLongFunction

        public static Type toLongFunction​(Type innerType)
        Generates a Type to represent a java standard ToLongFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • toDoubleFunction

        public static Type toDoubleFunction​(Type innerType)
        Generates a Type to represent a java standard ToDoubleFunction with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • unaryOperator

        public static Type unaryOperator​(Type innerType)
        Generates a Type to represent a java standard UnaryOperator with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • binaryOperator

        public static Type binaryOperator​(Type innerType)
        Generates a Type to represent a java standard BinaryOperator with generic type variables.
        Parameters:
        innerType - the inner type
        Returns:
        the resulting type
        Since:
        2.5
      • predicate

        public static Type predicate​(Type innerType)
        Generates a Type to represent a java standard Predicate with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • bipredicate

        public static Type bipredicate​(Type innerTypeA,
                                       Type innerTypeB)
        Generates a Type to represent a java standard BiPredicate with a generic type variable.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        Returns:
        the resulting type
        Since:
        2.5
      • consumer

        public static Type consumer​(Type innerType)
        Generates a Type to represent a java standard Consumer with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • biconsumer

        public static Type biconsumer​(Type innerTypeA,
                                      Type innerTypeB)
        Generates a Type to represent a java standard Consumer with a generic type variable.
        Parameters:
        innerTypeA - the first type variable
        innerTypeB - the second type variable
        Returns:
        the resulting type
        Since:
        2.5
      • supplier

        public static Type supplier​(Type innerType)
        Generates a Type to represent a java standard Supplier with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • stream

        public static Type stream​(Type innerType)
        Generates a Type to represent a java standard Stream with a generic type variable.
        Parameters:
        innerType - the type variable
        Returns:
        the resulting type
      • isPrimitive

        public static boolean isPrimitive​(Type type)
        Returns true if the specified type is a primitive type. Wrapper types does not count as primitives.
        Parameters:
        type - the type to check
        Returns:
        true if it is primitive, else false
      • isWrapper

        public static boolean isWrapper​(Type type)
        Returns true if the specified type is a wrapper type, else false.
        Parameters:
        type - the type to check
        Returns:
        true if it is a wrapper, else false
        Since:
        2.5
      • wrapperFor

        public static Class<?> wrapperFor​(Type primitiveType)
        Returns the corresponding wrapper type for the specified primitive type. If the type is not primitive, an exception is thrown.
        Parameters:
        primitiveType - the primitive type
        Returns:
        the corresponding wrapper type
      • primitiveTypes

        public static Stream<Type> primitiveTypes()
        Returns a stream of all the primitive types in the java language.
        Returns:
        stream of types
      • wrapperTypes

        public static Stream<Type> wrapperTypes()
        Returns a stream of all the wrapper types in the java language.
        Returns:
        stream of types