Class StepChain
- All Implemented Interfaces:
AST,PipelineAST
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStepChain(List<StepDeclaration> steps) StepChain(List<StepDeclaration> steps, List<Token> links) -
Method Summary
Modifier and TypeMethodDescription<T,R> R accept(PipelineVisitor<T, R> visitor, T data) Returns a new StepChain with all the steps from the given chain appended to this chainappend(StepDeclaration stepDeclaration) Returns a new StepChain with the given step appendedprotected voidappendSource(StringBuilder appendTo) Implementers extend this to append their source to the given string builder.protected static voidappendSource(AST ast, StringBuilder appendTo) Helper method for appending the source of another ast element to a string builder, efficiently if possible.protected voidappendString(StringBuilder appendTo) Append a simplified string representation to the builder.protected booleanbooleangetFirst()Nicer form of StepChain#getSteps().get(0)getLast()Nicer form ofStepChain.getSteps().get(StepChain.getSteps().size() - 1);getLink(int index) intgetSteps()inthashCode()replace(StepDeclaration step, StepDeclaration replacement) Replacestepwith `replacement, returning a newStepChainthat includes the change.intsize()final StringtoSource()final StringtoString()Returns a simplified view of the ast in a source-like fashion, but with a lot of details left out for concisenessMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface nz.org.riskscape.rl.ast.AST
isA, switchType, toSource
-
Field Details
-
CHAIN_TOKEN
A handy constant for building AST in code (instead of parsing it)
-
EMPTY
-
-
Constructor Details
-
StepChain
-
StepChain
-
-
Method Details
-
getBoundary
- Specified by:
getBoundaryin interfaceAST- 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.
-
append
Returns a new StepChain with all the steps from the given chain appended to this chain
-
append
Returns a new StepChain with the given step appended
-
appendSource
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.
-
appendString
Append a simplified string representation to the builder. Default implementation uses appendSource. Subclasses can override to provide a more concise representation.
-
getFirst
Nicer form of StepChain#getSteps().get(0)
- Throws:
IndexOutOfBoundsException- if this chain is empty
-
getLast
Nicer form of
StepChain.getSteps().get(StepChain.getSteps().size() - 1);- Throws:
IndexOutOfBoundsException- if this chain is empty
-
getLink
-
getLinkCount
public int getLinkCount() -
size
public int size()- Returns:
- the number of steps in this chain
-
replace
Replace
stepwith `replacement, returning a newStepChainthat includes the change. -
accept
- Specified by:
acceptin interfacePipelineAST
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getSteps
-
appendSource
Helper method for appending the source of another ast element to a string builder, efficiently if possible.
-
toString
Returns a simplified view of the ast in a source-like fashion, but with a lot of details left out for conciseness
-
toSource
-