Class SelectAllExpression

java.lang.Object
nz.org.riskscape.rl.ast.SelectAllExpression
All Implemented Interfaces:
Expression

public class SelectAllExpression extends Object

A 'select all' expression is an asterisk by itself (i.e. not indexing some other expression), and is currently only supported to appear within a struct expression, e.g. {*, foo} or {foo, *}.

A select all expression will add any members from the input scope to the struct you are declaring, so something like... input(expression: {foo: 1}) -> select({*, bar: 2}) would yield {foo: 1, bar: 2}

A related expression is a PropertyAccess expression with a trailing select all, e.g. foo().bar.*

  • Constructor Details

    • SelectAllExpression

      public SelectAllExpression(Token token)
  • Method Details

    • appendSource

      protected void appendSource(StringBuilder appendTo)

      Implementers extend this to append their source to the given string builder. Done via string builder to encourage a more efficient implementation than is possible with concatenating multiple toString calls that typically contruct a string builder anyway.

    • getBoundary

      public Optional<Pair<Token,Token>> getBoundary()
      Returns:
      a pair of tokens that represent the start and end of this expression, to be used when giving users information about where errors have occurred. If the expression has been rebuilt then the boundary may be empty or it may be from the original expression. Intended for use in problems to trace errors back to their source.
    • accept

      public <T, R> R accept(ExpressionVisitor<T,R> visitor, T data)
    • equals

      public boolean equals(Object o)
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
    • getToken

      public Token getToken()
    • toString

      public final String toString()
      Overrides:
      toString in class Object
      Returns:
      the source, surrounded by the class name to make it easier to discern from a plane string among other debug output
    • toSource

      public final String toSource()
      Specified by:
      toSource in interface Expression
      Returns:
      a normalized version of the AST that can be parsed to be exactly the same AST as this