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
Specializes a comparison against
null for static compilation.-
Field Summary
Fields inherited from class org.codehaus.groovy.ast.expr.Expression
EMPTY_ARRAYFields inherited from interface groovy.lang.groovydoc.GroovydocHolder
DOC_COMMENT -
Constructor Summary
ConstructorsConstructorDescriptionCompareToNullExpression(Expression expression, boolean equalsNull) Creates a comparison between an expression andnull. -
Method Summary
Modifier and TypeMethodDescriptionReturns the expression being compared withnull.voidsetLeftExpression(Expression expression) Prevents replacing the compared expression after construction.voidsetRightExpression(Expression expression) Prevents changing the fixednullright-hand operand.voidPrevents changing the fixed boolean result type of this expression.transformExpression(ExpressionTransformer transformer) Transforms the compared expression while preserving thenull-comparison semantics.voidvisit(GroovyCodeVisitor visitor) Emits directnull-comparison bytecode for this expression.Methods inherited from class org.codehaus.groovy.ast.expr.BinaryExpression
getLeftExpression, getOperation, getRightExpression, getText, isSafe, newAssignmentExpression, newInitializationExpression, setSafe, toStringMethods inherited from class org.codehaus.groovy.ast.expr.Expression
getType, transformExpressions, transformExpressionsMethods inherited from class org.codehaus.groovy.ast.AnnotatedNode
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSyntheticMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
CompareToNullExpression
Creates a comparison between an expression andnull.- Parameters:
expression- the expression being comparedequalsNull-truefor== null;falsefor!= null
-
-
Method Details
-
getObjectExpression
Returns the expression being compared withnull.- Returns:
- the compared expression
-
setLeftExpression
Prevents replacing the compared expression after construction.- Overrides:
setLeftExpressionin classBinaryExpression- Parameters:
expression- ignored- Throws:
UnsupportedOperationException- always
-
setRightExpression
Prevents changing the fixednullright-hand operand.- Overrides:
setRightExpressionin classBinaryExpression- Parameters:
expression- ignored- Throws:
UnsupportedOperationException- always
-
setType
Prevents changing the fixed boolean result type of this expression.- Overrides:
setTypein classExpression- Parameters:
type- ignored- Throws:
UnsupportedOperationException- always
-
transformExpression
Transforms the compared expression while preserving thenull-comparison semantics.- Overrides:
transformExpressionin classBinaryExpression- Parameters:
transformer- the expression transformer to apply- Returns:
- a transformed
null-comparison expression
-
visit
Emits directnull-comparison bytecode for this expression.- Overrides:
visitin classBinaryExpression- Parameters:
visitor- the visitor to accept
-