Package org.codehaus.groovy.transform.sc.transformers

# Class CompareToNullExpression

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.expr.Expression
org.codehaus.groovy.ast.expr.BinaryExpression
org.codehaus.groovy.transform.sc.transformers.CompareToNullExpression

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`

public class CompareToNullExpression extends BinaryExpression
Specializes a comparison against `null` for static compilation.

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.ast.expr.Expression

  `EMPTY_ARRAY`

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CompareToNullExpression(Expression expression, boolean equalsNull)`
  Creates a comparison between an expression and `null`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Expression`
  `getObjectExpression()`
  Returns the expression being compared with `null`.
  `void`
  `setLeftExpression(Expression expression)`
  Prevents replacing the compared expression after construction.
  `void`
  `setRightExpression(Expression expression)`
  Prevents changing the fixed `null` right-hand operand.
  `void`
  `setType(ClassNode type)`
  Prevents changing the fixed boolean result type of this expression.
  `Expression`
  `transformExpression(ExpressionTransformer transformer)`
  Transforms the compared expression while preserving the `null`-comparison semantics.
  `void`
  `visit(GroovyCodeVisitor visitor)`
  Emits direct `null`-comparison bytecode for this expression.

  ### Methods inherited from class org.codehaus.groovy.ast.expr.BinaryExpression

  `getLeftExpression, getOperation, getRightExpression, getText, isSafe, newAssignmentExpression, newInitializationExpression, setSafe, toString`

  ### Methods inherited from class org.codehaus.groovy.ast.expr.Expression

  `getType, transformExpressions, transformExpressions`

  ### Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode

  `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### CompareToNullExpression

    public CompareToNullExpression(Expression expression, boolean equalsNull)
    Creates a comparison between an expression and `null`.
    Parameters:
      `expression` - the expression being compared
      `equalsNull` - `true` for `== null`; `false` for `!= null`

- ## Method Details

  - ### getObjectExpression

    public Expression getObjectExpression()
    Returns the expression being compared with `null`.
    Returns:
      the compared expression

  - ### setLeftExpression

    public void setLeftExpression(Expression expression)
    Prevents replacing the compared expression after construction.
    Overrides:
      `setLeftExpression` in class `BinaryExpression`
    Parameters:
      `expression` - ignored
    Throws:
      `UnsupportedOperationException` - always

  - ### setRightExpression

    public void setRightExpression(Expression expression)
    Prevents changing the fixed `null` right-hand operand.
    Overrides:
      `setRightExpression` in class `BinaryExpression`
    Parameters:
      `expression` - ignored
    Throws:
      `UnsupportedOperationException` - always

  - ### setType

    public void setType(ClassNode type)
    Prevents changing the fixed boolean result type of this expression.
    Overrides:
      `setType` in class `Expression`
    Parameters:
      `type` - ignored
    Throws:
      `UnsupportedOperationException` - always

  - ### transformExpression

    public Expression transformExpression(ExpressionTransformer transformer)
    Transforms the compared expression while preserving the `null`-comparison semantics.
    Overrides:
      `transformExpression` in class `BinaryExpression`
    Parameters:
      `transformer` - the expression transformer to apply
    Returns:
      a transformed `null`-comparison expression

  - ### visit

    public void visit(GroovyCodeVisitor visitor)
    Emits direct `null`-comparison bytecode for this expression.
    Overrides:
      `visit` in class `BinaryExpression`
    Parameters:
      `visitor` - the visitor to accept