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

## [Java] Class CompareToNullExpression

- org.codehaus.groovy.transform.sc.transformers.CompareToNullExpression

-     public class CompareToNullExpression
      extends BinaryExpression

  Specializes a comparison against `null` for static compilation.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class Expression` | `EMPTY_ARRAY`

  - ### Constructor Summary

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

  - ### Methods Summary

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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BinaryExpression` | `getLeftExpression, getOperation, getRightExpression, getText, isSafe, newAssignmentExpression, newInitializationExpression, setLeftExpression, setRightExpression, setSafe, toString, transformExpression, visit`
    `class Expression` | `getType, setType, transformExpression, transformExpressions, transformExpressions`
    `class AnnotatedNode` | `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### 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 Detail

    - #### public Expression getObjectExpression()

      Returns the expression being compared with `null`.

      Returns:
        the compared expression

    - #### public void setLeftExpression(Expression expression)

      Prevents replacing the compared expression after construction.

      throws:
        UnsupportedOperationException always
      Parameters:
        `expression` - ignored

    - #### public void setRightExpression(Expression expression)

      Prevents changing the fixed `null` right-hand operand.

      throws:
        UnsupportedOperationException always
      Parameters:
        `expression` - ignored

    - #### public void setType(ClassNode type)

      Prevents changing the fixed boolean result type of this expression.

      throws:
        UnsupportedOperationException always
      Parameters:
        `type` - ignored

    - #### public Expression transformExpression(ExpressionTransformer transformer)

      Transforms the compared expression while preserving the `null`-comparison semantics.

      Parameters:
        `transformer` - the expression transformer to apply
      Returns:
        a transformed `null`-comparison expression

    - #### public void visit(GroovyCodeVisitor visitor)

      Emits direct `null`-comparison bytecode for this expression.

      Parameters:
        `visitor` - the visitor to accept