Interface JExpr

All Known Subinterfaces:
JAnonymousClassDef, JArrayExpr, JAssignableExpr, JCall, JLambda
All Known Implementing Classes:
AbstractJAssignableExpr, AbstractJCall, AbstractJExpr, AbstractMethodJCall, ArrayLookupJExpr, AssignmentJExpr, BinaryJExpr, BooleanJExpr, CastJExpr, CharJExpr, CondJExpr, DecimalDoubleJExpr, DecimalFloatJExpr, DirectJCall, FieldRefJExpr, HexDoubleJExpr, HexFloatJExpr, ImplJAnonymousClassDef, IncDecJExpr, InnerJAnonymousClassDef, InnerNewJCall, InstanceJCall, InstanceOfJExpr, IntegerJExpr, JLambdaImpl, KeywordJCall, KeywordJExpr, LongJExpr, MethodRefJExpr, NameJExpr, NewDimJArrayExpr, NewJCall, NewUndimJArrayExpr, ParenJExpr, PlainJArrayExpr, StaticJCall, StaticRefJExpr, StringJExpr, UnaryJExpr

public interface JExpr
A modelled expression. Constructed complex expressions are reusable (their contents will be copied at every use site). The minimum number of parentheses will automatically be added as needed. For convenience methods to construct common expressions, also see the JExprs class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final JExpr
    The constant expression for false.
    static final JExpr
    The constant expression for null.
    static final JExpr
    The constant expression for the integer one.
    static final JExpr
    The constant expression for this.
    static final JExpr
    The constant expression for true.
    static final JExpr
    The constant expression for the integer zero.
  • Method Summary

    Modifier and Type
    Method
    Description
    _instanceof(Class<?> type)
    Get a type-testing expression using the instanceof operator.
    Get a type-testing expression using the instanceof operator.
    Get a type-testing expression using the instanceof operator.
    _new(Class<?> type)
    Get an expression to construct a new inner class instance of this instance expression.
    _new(String type)
    Get an expression to construct a new inner class instance of this instance expression.
    _new(JType type)
    Get an expression to construct a new inner class instance of this instance expression.
    _newAnon(Class<?> type)
    Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
    Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
    Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
    $v(String name)
    Get a field of this object instance (shorthand for field(String).
    and(JExpr e1)
    Combine this expression with another using the binary && operator.
    band(JExpr e1)
    Combine this expression with another using the binary & operator.
    bor(JExpr e1)
    Combine this expression with another using the binary | operator.
    bxor(JExpr e1)
    Combine this expression with another using the binary ^ operator.
    call(String name)
    Call the given method on this expression.
    cast(Class<?> type)
    Get an expression which is a cast of this expression to the given type.
    cast(String type)
    Get an expression which is a cast of this expression to the given type.
    cast(JType type)
    Get an expression which is a cast of this expression to the given type.
    Invert this expression using the unary ~ operator.
    cond(JExpr ifTrue, JExpr ifFalse)
    Combine this expression with two others using the ternary ? : operator.
    div(JExpr e1)
    Combine this expression with another using the binary / operator.
    eq(JExpr e1)
    Combine this expression with another using the binary == operator.
    field(String name)
    Get a field of this object instance.
    ge(JExpr e1)
    Combine this expression with another using the binary >= operator.
    gt(JExpr e1)
    Combine this expression with another using the binary > operator.
    idx(int idx)
    Get an element of this array expression.
    idx(JExpr idx)
    Get an element of this array expression.
    le(JExpr e1)
    Combine this expression with another using the binary <= operator.
    Get the length expression of this array expression.
    lshr(JExpr e1)
    Combine this expression with another using the binary >>> operator.
    lt(JExpr e1)
    Combine this expression with another using the binary < operator.
    Combine this expression with another using the binary - operator.
    mod(JExpr e1)
    Combine this expression with another using the binary % operator.
    ne(JExpr e1)
    Combine this expression with another using the binary != operator.
    neg()
    Negate this expression using the unary - operator.
    not()
    Invert this expression using the unary ! operator.
    or(JExpr e1)
    Combine this expression with another using the binary || operator.
    Explicitly wrap this expression in parentheses.
    plus(JExpr e1)
    Combine this expression with another using the binary + operator.
    shl(JExpr e1)
    Combine this expression with another using the binary << operator.
    shr(JExpr e1)
    Combine this expression with another using the binary >> operator.
    Combine this expression with another using the binary * operator.
  • Field Details

    • FALSE

      static final JExpr FALSE
      The constant expression for false.
    • TRUE

      static final JExpr TRUE
      The constant expression for true.
    • THIS

      static final JExpr THIS
      The constant expression for this.
    • NULL

      static final JExpr NULL
      The constant expression for null.
    • ZERO

      static final JExpr ZERO
      The constant expression for the integer zero.
    • ONE

      static final JExpr ONE
      The constant expression for the integer one.
  • Method Details

    • plus

      JExpr plus(JExpr e1)
      Combine this expression with another using the binary + operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • minus

      JExpr minus(JExpr e1)
      Combine this expression with another using the binary - operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • times

      JExpr times(JExpr e1)
      Combine this expression with another using the binary * operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • div

      JExpr div(JExpr e1)
      Combine this expression with another using the binary / operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • mod

      JExpr mod(JExpr e1)
      Combine this expression with another using the binary % operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • neg

      JExpr neg()
      Negate this expression using the unary - operator.
      Returns:
      the new expression
    • band

      JExpr band(JExpr e1)
      Combine this expression with another using the binary & operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • bor

      JExpr bor(JExpr e1)
      Combine this expression with another using the binary | operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • bxor

      JExpr bxor(JExpr e1)
      Combine this expression with another using the binary ^ operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • shr

      JExpr shr(JExpr e1)
      Combine this expression with another using the binary >> operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • lshr

      JExpr lshr(JExpr e1)
      Combine this expression with another using the binary >>> operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • shl

      JExpr shl(JExpr e1)
      Combine this expression with another using the binary << operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • comp

      JExpr comp()
      Invert this expression using the unary ~ operator.
      Returns:
      the new expression
    • and

      JExpr and(JExpr e1)
      Combine this expression with another using the binary && operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • or

      JExpr or(JExpr e1)
      Combine this expression with another using the binary || operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • not

      JExpr not()
      Invert this expression using the unary ! operator.
      Returns:
      the new expression
    • eq

      JExpr eq(JExpr e1)
      Combine this expression with another using the binary == operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • ne

      JExpr ne(JExpr e1)
      Combine this expression with another using the binary != operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • lt

      JExpr lt(JExpr e1)
      Combine this expression with another using the binary < operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • gt

      JExpr gt(JExpr e1)
      Combine this expression with another using the binary > operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • le

      JExpr le(JExpr e1)
      Combine this expression with another using the binary <= operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • ge

      JExpr ge(JExpr e1)
      Combine this expression with another using the binary >= operator.
      Parameters:
      e1 - the other expression
      Returns:
      the combined expression
    • cond

      JExpr cond(JExpr ifTrue, JExpr ifFalse)
      Combine this expression with two others using the ternary ? : operator.
      Parameters:
      ifTrue - the true expression branch
      ifFalse - the false expression branch
      Returns:
      the combined expression
    • paren

      JExpr paren()
      Explicitly wrap this expression in parentheses.
      Returns:
      the wrapped expression
    • _instanceof

      JExpr _instanceof(String type)
      Get a type-testing expression using the instanceof operator.
      Parameters:
      type - the type to test
      Returns:
      the expression
    • _instanceof

      JExpr _instanceof(JType type)
      Get a type-testing expression using the instanceof operator.
      Parameters:
      type - the type to test
      Returns:
      the expression
    • _instanceof

      JExpr _instanceof(Class<?> type)
      Get a type-testing expression using the instanceof operator.
      Parameters:
      type - the type to test
      Returns:
      the expression
    • cast

      JExpr cast(String type)
      Get an expression which is a cast of this expression to the given type.
      Parameters:
      type - the type to cast to
      Returns:
      the expression
    • cast

      JExpr cast(JType type)
      Get an expression which is a cast of this expression to the given type.
      Parameters:
      type - the type to cast to
      Returns:
      the expression
    • cast

      JExpr cast(Class<?> type)
      Get an expression which is a cast of this expression to the given type.
      Parameters:
      type - the type to cast to
      Returns:
      the expression
    • call

      JCall call(String name)
      Call the given method on this expression.
      Parameters:
      name - the method name
      Returns:
      the method call
    • _new

      JCall _new(String type)
      Get an expression to construct a new inner class instance of this instance expression.
      Parameters:
      type - the inner class type to construct
      Returns:
      the new constructor call
    • _new

      JCall _new(JType type)
      Get an expression to construct a new inner class instance of this instance expression.
      Parameters:
      type - the inner class type to construct
      Returns:
      the new constructor call
    • _new

      JCall _new(Class<?> type)
      Get an expression to construct a new inner class instance of this instance expression.
      Parameters:
      type - the inner class type to construct
      Returns:
      the new constructor call
    • _newAnon

      JAnonymousClassDef _newAnon(String type)
      Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
      Parameters:
      type - the type of object to construct
      Returns:
      the anonymous subclass definition
    • _newAnon

      JAnonymousClassDef _newAnon(JType type)
      Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
      Parameters:
      type - the type of object to construct
      Returns:
      the anonymous subclass definition
    • _newAnon

      JAnonymousClassDef _newAnon(Class<?> type)
      Construct a new anonymous subclass of the given type, which must be an inner class of the type of this expression.
      Parameters:
      type - the type of object to construct
      Returns:
      the anonymous subclass definition
    • field

      JAssignableExpr field(String name)
      Get a field of this object instance.
      Parameters:
      name - the field name
      Returns:
      the expression
    • $v

      Get a field of this object instance (shorthand for field(String).
      Parameters:
      name - the field name
      Returns:
      the expression
    • idx

      Get an element of this array expression.
      Parameters:
      idx - the array index expression
      Returns:
      the array dereference expression
    • idx

      JExpr idx(int idx)
      Get an element of this array expression.
      Parameters:
      idx - the array index
      Returns:
      the array dereference expression
    • length

      JExpr length()
      Get the length expression of this array expression.
      Returns:
      the length expression