Interface Types


  • public interface Types
    Factory for types. Allows creating representations of the void pseudo-type, primitive types, class types, array types, parameterized types and wildcard types.
    Since:
    4.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      jakarta.enterprise.lang.model.types.Type of​(java.lang.Class<?> clazz)
      Returns a type from given class literal.
      jakarta.enterprise.lang.model.types.ArrayType ofArray​(jakarta.enterprise.lang.model.types.Type elementType, int dimensions)
      Returns an ArrayType for the given element type and number of dimensions.
      jakarta.enterprise.lang.model.types.ClassType ofClass​(jakarta.enterprise.lang.model.declarations.ClassInfo clazz)
      Returns a ClassType for the given class declaration.
      jakarta.enterprise.lang.model.types.ClassType ofClass​(java.lang.String name)
      Returns a ClassType for the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned by Class.getName().
      jakarta.enterprise.lang.model.types.PrimitiveType ofPrimitive​(jakarta.enterprise.lang.model.types.PrimitiveType.PrimitiveKind kind)
      Returns a PrimitiveType for the given kind of primitive type.
      jakarta.enterprise.lang.model.types.VoidType ofVoid()
      Returns a VoidType, representing the void pseudo-type.
      jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(jakarta.enterprise.lang.model.types.ClassType genericType, jakarta.enterprise.lang.model.types.Type... typeArguments)
      Returns a ParameterizedType for the given generic type and type arguments.
      jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(java.lang.Class<?> genericType, jakarta.enterprise.lang.model.types.Type... typeArguments)
      Returns a ParameterizedType for the given generic type and type arguments.
      jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(java.lang.Class<?> genericType, java.lang.Class<?>... typeArguments)
      Returns a ParameterizedType for the given generic type and type arguments.
      jakarta.enterprise.lang.model.types.WildcardType wildcardUnbounded()
      Returns a WildcardType that represents an equivalent of ?.
      jakarta.enterprise.lang.model.types.WildcardType wildcardWithLowerBound​(jakarta.enterprise.lang.model.types.Type lowerBound)
      Returns a WildcardType that represents an equivalent of ? super lowerBound.
      jakarta.enterprise.lang.model.types.WildcardType wildcardWithUpperBound​(jakarta.enterprise.lang.model.types.Type upperBound)
      Returns a WildcardType that represents an equivalent of ? extends upperBound.
    • Method Detail

      • of

        jakarta.enterprise.lang.model.types.Type of​(java.lang.Class<?> clazz)
        Returns a type from given class literal. For example:
        • of(void.class): same as ofVoid()
        • of(int.class): same as ofPrimitive(PrimitiveKind.INT)
        • of(String.class): same as ofClass(... ClassInfo for String ...)
        • of(int[].class): same as ofArray(ofPrimitive(PrimitiveKind.INT), 1)
        • of(String[][].class): same as ofArray(ofClass(... ClassInfo for String ...), 2)
        Parameters:
        clazz - the class literal, must not be null
        Returns:
        Type object representing the given class literal
      • ofVoid

        jakarta.enterprise.lang.model.types.VoidType ofVoid()
        Returns a VoidType, representing the void pseudo-type.
        Returns:
        the VoidType, never null
      • ofPrimitive

        jakarta.enterprise.lang.model.types.PrimitiveType ofPrimitive​(jakarta.enterprise.lang.model.types.PrimitiveType.PrimitiveKind kind)
        Returns a PrimitiveType for the given kind of primitive type.
        Parameters:
        kind - the primitive type kind, must not be null
        Returns:
        the PrimitiveType, never null
      • ofClass

        jakarta.enterprise.lang.model.types.ClassType ofClass​(java.lang.String name)
        Returns a ClassType for the given binary name, as defined by The Java™ Language Specification; in other words, the class name as returned by Class.getName().

        Note that this method returns ClassType, so name may only be a name of a class. For primitives, use ofPrimitive(PrimitiveType.PrimitiveKind). For arrays, use ofArray(Type, int).

        Parameters:
        name - the binary name of the class, must not be null
        Returns:
        the ClassType or null if the class is not present in any bean archive
      • ofClass

        jakarta.enterprise.lang.model.types.ClassType ofClass​(jakarta.enterprise.lang.model.declarations.ClassInfo clazz)
        Returns a ClassType for the given class declaration.
        Parameters:
        clazz - the ClassInfo, must not be null
        Returns:
        the ClassType, never null
      • ofArray

        jakarta.enterprise.lang.model.types.ArrayType ofArray​(jakarta.enterprise.lang.model.types.Type elementType,
                                                              int dimensions)
        Returns an ArrayType for the given element type and number of dimensions.

        Note that this method accepts the element type of an array, even though ArrayType uses a component type representation. For example, the component type of String[][] is String[], while the element type is String.

        Parameters:
        elementType - the element Type, must not be null
        dimensions - the number of dimensions
        Returns:
        the ArrayType, never null
        Throws:
        java.lang.IllegalArgumentException - if the element type is an array type, a wildcard type, or the void pseudo-type
      • parameterized

        jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(java.lang.Class<?> genericType,
                                                                            java.lang.Class<?>... typeArguments)
        Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.
        Parameters:
        genericType - the type to parameterize, must not be null
        typeArguments - one or more type arguments
        Returns:
        the parameterized type, never null
        Throws:
        java.lang.IllegalArgumentException - if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
      • parameterized

        jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(java.lang.Class<?> genericType,
                                                                            jakarta.enterprise.lang.model.types.Type... typeArguments)
        Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.
        Parameters:
        genericType - the type to parameterize, must not be null
        typeArguments - one or more type arguments
        Returns:
        the parameterized type, never null
        Throws:
        java.lang.IllegalArgumentException - if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
      • parameterized

        jakarta.enterprise.lang.model.types.ParameterizedType parameterized​(jakarta.enterprise.lang.model.types.ClassType genericType,
                                                                            jakarta.enterprise.lang.model.types.Type... typeArguments)
        Returns a ParameterizedType for the given generic type and type arguments. The array of type arguments must have the same shape as the generic type's list of type parameters.
        Parameters:
        genericType - the type to parameterize, must not be null
        typeArguments - one or more type arguments
        Returns:
        the parameterized type, never null
        Throws:
        java.lang.IllegalArgumentException - if given genericType is not generic or if the number of type arguments does not match the number of type parameters declared by genericType
      • wildcardWithUpperBound

        jakarta.enterprise.lang.model.types.WildcardType wildcardWithUpperBound​(jakarta.enterprise.lang.model.types.Type upperBound)
        Returns a WildcardType that represents an equivalent of ? extends upperBound. Note that if upperBound represents the java.lang.Object type, then the result is equivalent to wildcardUnbounded().
        Parameters:
        upperBound - upper bound type, must not be null
        Returns:
        a WildcardType object representing a wildcard type with given upper bound
      • wildcardWithLowerBound

        jakarta.enterprise.lang.model.types.WildcardType wildcardWithLowerBound​(jakarta.enterprise.lang.model.types.Type lowerBound)
        Returns a WildcardType that represents an equivalent of ? super lowerBound.
        Parameters:
        lowerBound - lower bound type, must not be null
        Returns:
        a WildcardType object representing a wildcard type with given upper bound
      • wildcardUnbounded

        jakarta.enterprise.lang.model.types.WildcardType wildcardUnbounded()
        Returns a WildcardType that represents an equivalent of ?.
        Returns:
        a WildcardType object representing an unbounded wildcard type