Interface JType

All Known Implementing Classes:
AbstractJType, ArrayJType, NarrowedJType, NestedJType, PrimitiveJType, ReferenceJType, ThisJType, WildcardJType

public interface JType
A type specification. See also JTypes.
  • Field Details

    • 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 Details

    • simpleName

      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(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(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(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(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(String name)
      Look up a static field on this type.
      Parameters:
      name - the field name
      Returns:
      the field expression
    • $v

      Look up a static field on this type.
      Parameters:
      name - the field name
      Returns:
      the field expression
    • call

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

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

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

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