Class MapEntryExpression

All Implemented Interfaces:
GroovydocHolder<AnnotatedNode>, NodeMetaDataHandler

public class MapEntryExpression extends Expression
Represents an entry inside a map expression such as 1 : 2 or 'foo' : 'bar'.
  • Constructor Details

    • MapEntryExpression

      public MapEntryExpression(Expression keyExpression, Expression valueExpression)
      Builds a map entry from the key and value expressions.
      Parameters:
      keyExpression - expression on the left of the colon
      valueExpression - expression on the right of the colon
  • Method Details

    • visit

      public void visit(GroovyCodeVisitor visitor)
      Description copied from class: ASTNode
      Accepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.
      Overrides:
      visit in class ASTNode
      Parameters:
      visitor - the GroovyCodeVisitor to process this node
    • transformExpression

      public Expression transformExpression(ExpressionTransformer transformer)
      Description copied from class: Expression
      Transforms this expression and any nested expressions according to the provided transformer. This method is called during AST transformation phases and must recursively transform any nested expressions to support full AST tree transformation.
      Specified by:
      transformExpression in class Expression
      Parameters:
      transformer - the ExpressionTransformer to apply
      Returns:
      a transformed copy of this expression (or this expression itself if no changes are needed)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getKeyExpression

      public Expression getKeyExpression()
      Returns the key expression, the left side of the colon.
      Returns:
      the key expression
    • getValueExpression

      public Expression getValueExpression()
      Returns the value expression, the right side of the colon.
      Returns:
      the mapped expression
    • setKeyExpression

      public void setKeyExpression(Expression keyExpression)
      Replaces the key expression.
      Parameters:
      keyExpression - the expression to store on the left of the colon
    • setValueExpression

      public void setValueExpression(Expression valueExpression)
      Replaces the value expression.
      Parameters:
      valueExpression - the expression to store on the right of the colon