public class RangeExpression
extends Expression
Represents a range expression for creating range objects with bounded endpoints.
Supports inclusive ranges (e.g., 0..10) and exclusive ranges (e.g., 0..<10 or <0..10).
Range expressions are commonly used in for-loops (e.g., for (i in 0..10)) and other iteration contexts.
The type of a range expression is always ClassHelper.RANGE_TYPE.
| Fields inherited from class | Fields |
|---|---|
class Expression |
EMPTY_ARRAY |
| Constructor and description |
|---|
RangeExpression(Expression from, Expression to, boolean inclusive)Creates an inclusive or exclusive range expression. |
RangeExpression(Expression from, Expression to, boolean exclusiveLeft, boolean exclusiveRight)Creates a range expression with full control over inclusivity of both endpoints. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Expression |
getFrom()Returns the starting expression of the range. |
|
public String |
getText() |
|
public Expression |
getTo()Returns the ending expression of the range. |
|
public boolean |
isExclusiveLeft()Indicates whether the left endpoint is exclusive (uses <..). |
|
public boolean |
isExclusiveRight()Indicates whether the right endpoint is exclusive (uses ..<). |
|
public boolean |
isInclusive()Indicates whether this is an inclusive range (no exclusion on the right endpoint). |
|
public Expression |
transformExpression(ExpressionTransformer transformer) |
|
public void |
visit(GroovyCodeVisitor visitor) |
| Methods inherited from class | Name |
|---|---|
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 |
Creates an inclusive or exclusive range expression.
from - the starting expression (non-null)to - the ending expression (non-null)inclusive - true for inclusive range (no exclusion), false for exclusive right endpointCreates a range expression with full control over inclusivity of both endpoints.
from - the starting expression (non-null)to - the ending expression (non-null)exclusiveLeft - true if the left endpoint should be excluded (using <..)exclusiveRight - true if the right endpoint should be excluded (using ..<)Returns the starting expression of the range.
Returns the ending expression of the range.
Indicates whether the left endpoint is exclusive (uses <..).
Indicates whether the right endpoint is exclusive (uses ..<).
Indicates whether this is an inclusive range (no exclusion on the right endpoint).
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.