Class StepChain

java.lang.Object
nz.org.riskscape.pipeline.ast.StepChain
All Implemented Interfaces:
PipelineExpression

public class StepChain extends Object

AST for a list of StepDeclarations that are chained together.

Steps that are chained together should have their output connected to the input of the following step in the chain.

Steps that are declared (but not chained to another) will be on the only step in the step chain. In this case it would be expected that the the same step be present in another step chain to be chained together with other steps.

  • Field Details

    • CHAIN_TOKEN

      public static final Token CHAIN_TOKEN

      A handy constant for building AST in code (instead of parsing it)

    • EMPTY

      public static final StepChain EMPTY

      A special "empty" instance of a StepChain that can be used in place of null in various situations. Note that an empty StepChain is not a valid part of a pipeline.

  • Constructor Details

  • Method Details

    • getBoundary

      public Optional<Pair<Token,Token>> getBoundary()
    • append

      public StepChain append(StepChain appendStepsFrom)

      Returns a new StepChain with all the steps from the given chain appended to this chain

    • append

      public StepChain append(StepDeclaration stepDeclaration)

      Returns a new StepChain with the given step appended

    • appendSource

      protected void appendSource(StringBuilder appendTo)
    • appendString

      protected void appendString(StringBuilder appendTo)
    • getFirst

      public StepDeclaration getFirst()

      Nicer form of StepChain#getSteps().get(0)

      Throws:
      IndexOutOfBoundsException - if this chain is empty
    • getLast

      public StepDeclaration getLast()

      Nicer form of StepChain.getSteps().get(StepChain.getSteps().size() - 1);

      Throws:
      IndexOutOfBoundsException - if this chain is empty
    • getLink

      public StepLink getLink(int index)
    • getLinkCount

      public int getLinkCount()
    • size

      public int size()
      Returns:
      the number of steps in this chain
    • equals

      public boolean equals(Object o)
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
    • getSteps

      public List<StepDeclaration> getSteps()
    • 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
    • toSource

      public final String toSource()
      Specified by:
      toSource in interface PipelineExpression
      Returns:
      a string that can be parsed back in to the same ast as this one. It might not be whitespace-faithful...