Class BasePipelineChange<T>

java.lang.Object
nz.org.riskscape.wizard.bld.change.BasePipelineChange<T>
All Implemented Interfaces:
PipelineChange
Direct Known Subclasses:
AppendStepChange, StartChainChange

public abstract class BasePipelineChange<T> extends Object implements PipelineChange

Base class for any PipelineChange that follows a standard string -> ast -> validate -> update pattern

  • Constructor Details

    • BasePipelineChange

      public BasePipelineChange(Answer answer)
  • Method Details

    • toString

      public static String toString(Class<?> clazz, Answer answer, String extra)

      Template for a pipeline change tostring

    • make

      public final nz.org.riskscape.problem.ResultOrProblems<IncrementalBuildState> make(IncrementalBuildState state)
      Description copied from interface: PipelineChange

      Attempt to create a new IncrementalBuildState for this change

      Specified by:
      make in interface PipelineChange
      Returns:
      a new IncrementalBuildState with this change applied
    • validateParsedSegment

      protected abstract T validateParsedSegment(nz.org.riskscape.pipeline.ast.PipelineDeclaration declaration) throws BadPipelineChangeException

      Validate that the parsed pipeline segment is ok to use in this kind of change.

      Returns:
      the interesting bit of the pipeline, e.g. a single step, a step chain, whatever
      Throws:
      BadPipelineChangeException - if it's invalid - it has been coded badly (not a user error)
    • updateAst

      protected abstract nz.org.riskscape.pipeline.ast.PipelineDeclaration updateAst(IncrementalBuildState state, nz.org.riskscape.pipeline.ast.PipelineDeclaration astSegment, T validated)

      Build a new AST that is the result of this change

      Parameters:
      state - the previous build state that we are building upon
      astSegment - the segment that was parsed and validated. This is not the previous state's ast.
      validated - the chunk of the parsed segment that the validate routine method returned - this is often the node of interest that ultimately gets added to the previous state's ast
      Returns:
      a pipeline ast to be used in the next IncrementalBuildState
    • getSource

      protected abstract String getSource()

      TODO maybe break this up in to something else?

      Returns:
      the source code that was assembled to be parsed in to a PipelineDeclaration
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAnswer

      public Answer getAnswer()
      Specified by:
      getAnswer in interface PipelineChange
      Returns:
      the Answer that was ultimately responsible for this PipelineChange being introduced. Note that this might not be the only thing that predicated this change, but it is the last thing that caused it (the straw that broke the camel's back, so to speak)