Class InputChain

java.lang.Object
nz.org.riskscape.rl.ast.InputChain
All Implemented Interfaces:
AST, PipelineAST

public class InputChain extends Object implements PipelineAST

Represents a chain of input that is being sent as input to a step as a parameter, e.g. join(rhs: <- input(...) -> ...)

  • Constructor Details

    • InputChain

      public InputChain(Token inputToken, StepChain chain)

      Creates a new InputChain instance.

      Parameters:
      inputToken - The <- token
      chain -
  • Method Details

    • getBoundary

      public Optional<Pair<Token,Token>> getBoundary()
      Specified by:
      getBoundary in interface AST
      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 AST. Intended for use in problems to trace errors back to their source.
    • getStepReferences

      public List<StepReference> getStepReferences()
      Returns:
      a list of all the references to steps in the pipeline made from this input chain, e.g will return the foo step reference declared within the rhs of the join in input() as foo ... join(rhs: <- foo -> group())
    • accept

      public <T, R> R accept(PipelineVisitor<T,R> visitor, T data)
      Specified by:
      accept in interface PipelineAST
    • 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.

    • equals

      public boolean equals(Object obj)
    • hashCode

      public int hashCode()
    • getAsStepReference

      public Optional<StepReference> getAsStepReference()
      Returns:
      a step reference if that is the only item in this chain, e.g. the whole thing is just a reference to another step in the pipeline.
    • getInputToken

      public Token getInputToken()

      The <- token

    • getChain

      public StepChain getChain()
    • appendSource

      protected static void appendSource(AST ast, StringBuilder appendTo)

      Helper method for appending the source of another ast element to a string builder, efficiently if possible.

    • toString

      public final String toString()

      Returns a simplified view of the ast in a source-like fashion, but with a lot of details left out for conciseness

      Overrides:
      toString in class Object
    • appendString

      protected void appendString(StringBuilder appendTo)

      Append a simplified string representation to the builder. Default implementation uses appendSource. Subclasses can override to provide a more concise representation.

    • toSource

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