Interface JType

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static JType BOOLEAN
      The boolean primitive type.
      static JType BYTE
      The byte primitive type.
      static JType CHAR
      The char primitive type.
      static JType DOUBLE
      The double primitive type.
      static JType FLOAT
      The float primitive type.
      static JType INT
      The int primitive type.
      static JType LONG
      The long primitive type.
      static JType[] NONE
      An empty array of types.
      static JType OBJECT
      The type of java.lang.Object.
      static JType SHORT
      The short primitive type.
      static JType THIS
      A special type that always renders to the type of the class it is encountered in.
      static JType VOID
      The void type.
      static JType WILDCARD
      The wildcard type of <? extends Object>, also known as <?>.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      JExpr _class()
      An expression of the form ThisType.class.
      JCall _new()
      Construct a new instance of this non-array type.
      JExpr _new​(int dim)
      Construct a new instance of this array type.
      JExpr _new​(JExpr dim)
      Construct a new instance of this array type.
      JAnonymousClassDef _newAnon()
      Construct a new anonymous subclass of this type.
      JArrayExpr _newArray()
      Create a new array of this type which is inline-initialized.
      JExpr _super()
      An expression of the form ThisType.super.
      JExpr _this()
      An expression of the form ThisType.this.
      JType $t​(java.lang.String name)
      Get a nested type within this reference type.
      JAssignableExpr $v​(java.lang.String name)
      Look up a static field on this type.
      JType array()
      An array of this type.
      JType box()
      The primitive-boxed version of this type.
      JCall call​(java.lang.String name)
      Call a static method on this type.
      JCall call​(javax.lang.model.element.ExecutableElement method)
      Call a static method on this type.
      JType elementType()
      The element type, if this an array (otherwise null).
      JType erasure()
      The erasure of this type.
      JAssignableExpr field​(java.lang.String name)
      Look up a static field on this type.
      JExpr methodRef​(java.lang.String name)
      Get a method reference of this type.
      JExpr methodRef​(javax.lang.model.element.ExecutableElement method)
      Get a method reference of this type.
      JType nestedType​(java.lang.String name)
      Get a nested type within this reference type.
      java.lang.String simpleName()
      Get the simple name of this type.
      JType typeArg​(java.lang.Class<?>... args)
      This type, with the given generic type arguments.
      JType typeArg​(java.lang.String... args)
      This type, with the given generic type arguments.
      JType typeArg​(JType... args)
      This type, with the given generic type arguments.
      JType[] typeArgs()
      Get the type arguments of this type.
      JType unbox()
      The primitive-unboxed version of this type.
      JType wildcardExtends()
      Get a wildcard that extends this type.
      JType wildcardSuper()
      Get a wildcard that this type extends.
    • Field Detail

      • NONE

        static final JType[] NONE
        An empty array of types.
      • THIS

        static final JType THIS
        A special type that always renders to the type of the class it is encountered in.
      • VOID

        static final JType VOID
        The void type.
      • BOOLEAN

        static final JType BOOLEAN
        The boolean primitive type.
      • FLOAT

        static final JType FLOAT
        The float primitive type.
      • DOUBLE

        static final JType DOUBLE
        The double primitive type.
      • CHAR

        static final JType CHAR
        The char primitive type.
      • BYTE

        static final JType BYTE
        The byte primitive type.
      • SHORT

        static final JType SHORT
        The short primitive type.
      • INT

        static final JType INT
        The int primitive type.
      • LONG

        static final JType LONG
        The long primitive type.
      • OBJECT

        static final JType OBJECT
        The type of java.lang.Object.
      • WILDCARD

        static final JType WILDCARD
        The wildcard type of <? extends Object>, also known as <?>.
    • Method Detail

      • simpleName

        java.lang.String simpleName()
        Get the simple name of this type.
        Returns:
        the type's simple name
      • _class

        JExpr _class()
        An expression of the form ThisType.class.
        Returns:
        the expression
      • _this

        JExpr _this()
        An expression of the form ThisType.this. If the type is an array type, an exception is thrown.
        Returns:
        the expression
      • _super

        JExpr _super()
        An expression of the form ThisType.super. If the type is an array type, an exception is thrown.
        Returns:
        the expression
      • array

        JType array()
        An array of this type.
        Returns:
        the array type
      • _new

        JCall _new()
        Construct a new instance of this non-array type. If the type is an array type, an exception is thrown.
        Returns:
        the construction call
      • _new

        JExpr _new​(JExpr dim)
        Construct a new instance of this array type. If the type is not an array type, an exception is thrown.
        Parameters:
        dim - the array size
        Returns:
        the construction call
      • _new

        JExpr _new​(int dim)
        Construct a new instance of this array type. If the type is not an array type, an exception is thrown.
        Parameters:
        dim - the array size
        Returns:
        the construction call
      • _newArray

        JArrayExpr _newArray()
        Create a new array of this type which is inline-initialized.
        Returns:
        the array, initially with zero elements
      • _newAnon

        JAnonymousClassDef _newAnon()
        Construct a new anonymous subclass of this type.
        Returns:
        the anonymous subclass definition
      • typeArg

        JType typeArg​(java.lang.String... args)
        This type, with the given generic type arguments.
        Parameters:
        args - the type arguments
        Returns:
        the generic type
      • typeArg

        JType typeArg​(JType... args)
        This type, with the given generic type arguments.
        Parameters:
        args - the type arguments
        Returns:
        the generic type
      • typeArg

        JType typeArg​(java.lang.Class<?>... args)
        This type, with the given generic type arguments.
        Parameters:
        args - the type arguments
        Returns:
        the generic type
      • typeArgs

        JType[] typeArgs()
        Get the type arguments of this type.
        Returns:
        the type arguments of this type
      • box

        JType box()
        The primitive-boxed version of this type.
        Returns:
        the boxed version of this type
      • unbox

        JType unbox()
        The primitive-unboxed version of this type.
        Returns:
        the unboxed version of this type
      • erasure

        JType erasure()
        The erasure of this type.
        Returns:
        the erasure of this type
      • elementType

        JType elementType()
        The element type, if this an array (otherwise null).
        Returns:
        the element type, or null if it is not an array
      • wildcardExtends

        JType wildcardExtends()
        Get a wildcard that extends this type.
        Returns:
        the wildcard
      • wildcardSuper

        JType wildcardSuper()
        Get a wildcard that this type extends.
        Returns:
        the wildcard
      • nestedType

        JType nestedType​(java.lang.String name)
        Get a nested type within this reference type.
        Parameters:
        name - the name of the nested type
        Returns:
        the nested type
      • $t

        JType $t​(java.lang.String name)
        Get a nested type within this reference type.
        Parameters:
        name - the name of the nested type
        Returns:
        the nested type
      • field

        JAssignableExpr field​(java.lang.String name)
        Look up a static field on this type.
        Parameters:
        name - the field name
        Returns:
        the field expression
      • $v

        JAssignableExpr $v​(java.lang.String name)
        Look up a static field on this type.
        Parameters:
        name - the field name
        Returns:
        the field expression
      • call

        JCall call​(java.lang.String name)
        Call a static method on this type.
        Parameters:
        name - the method to call
        Returns:
        the method call
      • call

        JCall call​(javax.lang.model.element.ExecutableElement method)
        Call a static method on this type.
        Parameters:
        method - the method to call
        Returns:
        the method call
      • methodRef

        JExpr methodRef​(java.lang.String name)
        Get a method reference of this type.
        Parameters:
        name - the method name
        Returns:
        the method reference expression
      • methodRef

        JExpr methodRef​(javax.lang.model.element.ExecutableElement method)
        Get a method reference of this type.
        Parameters:
        method - the method element
        Returns:
        the method reference expression