Package com.libdbm.cel.ast
Record Class Comprehension
java.lang.Object
java.lang.Record
com.libdbm.cel.ast.Comprehension
- Record Components:
variable- the name of the iteration variablerange- the expression producing the iterable rangeaccumulator- the accumulator variable nameinitializer- the initial value of the accumulatorcondition- the loop continuation condition expressionstep- the expression that updates the accumulator per iterationresult- the expression that produces the final result value
- All Implemented Interfaces:
Expression
public record Comprehension(String variable, Expression range, String accumulator, Expression initializer, Expression condition, Expression step, Expression result)
extends Record
implements Expression
Represents a comprehension expression for generating lists or maps.
A comprehension has an iteration variable and range, an accumulator variable with its initialization, a loop condition and step expression, and a final result expression. This generalizes constructs like list and map comprehensions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.libdbm.cel.ast.Expression
Expression.Visitor<T> -
Constructor Summary
ConstructorsConstructorDescriptionComprehension(String variable, Expression range, String accumulator, Expression initializer, Expression condition, Expression step, Expression result) Creates an instance of aComprehensionrecord class. -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(Expression.Visitor<T> visitor) Accepts a visitor to perform operations on this expression node.Returns the value of theaccumulatorrecord component.Returns the value of theconditionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinitializerrecord component.range()Returns the value of therangerecord component.result()Returns the value of theresultrecord component.step()Returns the value of thesteprecord component.final StringtoString()Returns a string representation of this record class.variable()Returns the value of thevariablerecord component.
-
Constructor Details
-
Comprehension
public Comprehension(String variable, Expression range, String accumulator, Expression initializer, Expression condition, Expression step, Expression result) Creates an instance of aComprehensionrecord class.- Parameters:
variable- the value for thevariablerecord componentrange- the value for therangerecord componentaccumulator- the value for theaccumulatorrecord componentinitializer- the value for theinitializerrecord componentcondition- the value for theconditionrecord componentstep- the value for thesteprecord componentresult- the value for theresultrecord component
-
-
Method Details
-
accept
Accepts a visitor to perform operations on this expression node.Invokes the appropriate visit method on the provided visitor, dispatching the visit operation to the visitor implementation that corresponds to the type of this expression node.
- Specified by:
acceptin interfaceExpression- Type Parameters:
T- the return type of the visitor's visit operations- Parameters:
visitor- the visitor that will operate on this expression node- Returns:
- the result of the visitor's visit operation
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
variable
Returns the value of thevariablerecord component.- Returns:
- the value of the
variablerecord component
-
range
Returns the value of therangerecord component.- Returns:
- the value of the
rangerecord component
-
accumulator
Returns the value of theaccumulatorrecord component.- Returns:
- the value of the
accumulatorrecord component
-
initializer
Returns the value of theinitializerrecord component.- Returns:
- the value of the
initializerrecord component
-
condition
Returns the value of theconditionrecord component.- Returns:
- the value of the
conditionrecord component
-
step
Returns the value of thesteprecord component.- Returns:
- the value of the
steprecord component
-
result
Returns the value of theresultrecord component.- Returns:
- the value of the
resultrecord component
-