Class StepDeclaration

java.lang.Object
nz.org.riskscape.rl.ast.StepDeclaration
All Implemented Interfaces:
AST, PipelineAST
Direct Known Subclasses:
StepDefinition, StepReference

public abstract class StepDeclaration extends Object implements PipelineAST

AST for a single step.

  • Field Details

    • identToken

      protected final Token identToken

      The first identifier that starts this step declaration. Will be either the name of the referenced step (StepReference) or the id of a step being defined (StepDefinition).

    • namedInputToken

      protected final Optional<Token> namedInputToken

      The identifier that specifies a named input which accepts the previous step in the chain's output, e.g. the baz in foo -> bar.baz. Valid for references and definitions.

  • Constructor Details

    • StepDeclaration

      public StepDeclaration(Token identToken, Optional<Token> namedInputToken)

      Creates a new StepDeclaration instance.

      Parameters:
      identToken - The first identifier that starts this step declaration. Will be either the name of the referenced step (StepReference) or the id of a step being defined (StepDefinition).
      namedInputToken - The identifier that specifies a named input which accepts the previous step in the chain's output, e.g. the baz in foo -> bar.baz. Valid for references and definitions.
  • Method Details

    • getNamedInput

      public Optional<String> getNamedInput()

      Get the input name, if any, that the output should be directed to. Only applied to StepReferences.

      Returns:
      input name, if any
    • getIdent

      public String getIdent()
      Returns:
      the string value of this declaration's identifier
    • equals

      public boolean equals(Object o)
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
    • getIdentToken

      public Token getIdentToken()

      The first identifier that starts this step declaration. Will be either the name of the referenced step (StepReference) or the id of a step being defined (StepDefinition).

    • getNamedInputToken

      public Optional<Token> getNamedInputToken()

      The identifier that specifies a named input which accepts the previous step in the chain's output, e.g. the baz in foo -> bar.baz. Valid for references and definitions.

    • 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
    • appendSource

      protected abstract 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.