Class IncrementalBuildState


public class IncrementalBuildState extends Object

The results of building a pipeline incrementally in response to wizard Answers being supplied and PipelineChanges being made. This is a recursive data structure in that each state points to a previous state that was how the pipeline looked before the change was made.

  • Field Details


      public static final String START_STEP_NAME

      The non-answer for an empty question. Again, used instead of null in various situations.

      See Also:

      public static final QuestionSet EMPTY_QUESTION_SET

      The QuestionSet associated with an empty build state, i.e. when isEmpty() is true


      public static final Question EMPTY_QUESTION

      The Question associated with an empty build state, i.e. when isEmpty() is true


      public static final Answer EMPTY_ANSWER

      public static final Set<> START_STEPS_SET

      A set of RealizedStep that is returned from a QuestionSet's applicability method when it applies to an empty pipeline

  • Constructor Details

  • Method Details

    • empty

      Create a new, empty incremental build state using the given dependencies. This is the start state for building a pipeline incrementally via a Survey.

    • append

      public IncrementalBuildState append(@NonNull @NonNull PipelineChange newCreatedBy, @NonNull @NonNull newAst, @NonNull @NonNull newPipeline) throws IllegalArgumentException

      Return a new IncrementalBuildState that resulted in applying the given change to this build state.

      newCreatedBy - The PipelineChange that is responsible
      newAst - The pipeline ast that the PipelineChange created
      newPipeline - An illustrative fragment of the pipeline, used for validation purposes (so far)
      IllegalArgumentException - if the change references an Answer for a Question that has already been answered
    • buildStateIterator

      public Iterator<IncrementalBuildState> buildStateIterator()
      an Iterator that traverses the build state's stack, from latest change to oldest, excluding the empty state
    • buildStateStream

      public Stream<IncrementalBuildState> buildStateStream()
      a Stream that traverses the build state's stack, from latest change to oldest, excluding the empty state
    • isInvalid

      public boolean isInvalid()
      true if this state has resulted in an invalid pipeline. Please try again.
    • getRealizedStep

      public getRealizedStep() throws IllegalStateException

      Attempts to return the end step that resulted from this state.

      Will return the single (non-sink) end step if one exists. Otherwise if there are only SinkConstructor end steps then their dependency will be returned if that is the same for all of the sinks. Otherwise the IllegalStateException is thrown.

      IllegalStateException - If there is none, or there were multiple end steps, then this throws an exception
    • getInputStruct

      public getInputStruct(ChangeLocation location)
      the input scope Struct based on location, if known. Returns EMPTY_STRUCT if it couldn't be determined.
    • getInputStruct

      public getInputStruct(Question question)
      the input scope Struct available for this question, if known. Returns EMPTY_STRUCT if it couldn't be determined.
    • isEmpty

      public boolean isEmpty()
      true if this build state is the first, empty state.
    • getAnswer

      public Optional<Answer> getAnswer(String questionSetId, String questionName)
    • getAnswer

      public Optional<Answer> getAnswer(Question q)
      return an answer for the given question, based on the question's id (rather than testing object ==)
    • getResponse

      public <T> Optional<T> getResponse(String questionSetId, String questionName, Class<T> expectedResponseType)

      Optional-style version of getAnswerTo

    • getAnswersTo

      public <T> List<T> getAnswersTo(String questionSetId, String questionName, Class<T> expectedType)
      the responses recorded for a given question
    • getAnswerTo

      public <T> T getAnswerTo(String questionSetId, String questionName, Class<T> expectedType)
      the response recorded for a question, throwing an exception if the question wasn't a single-value response type question
    • realizePipeline

      public realizePipeline( pipeline)

      Helper method for changes etc to realize a pipeline that was created from a PipelineDeclaration (so no supplementary parameters required)

    • realizePipeline

      public<> realizePipeline( realizeThisAst)

      Helper method for attempting to construct and realize a pipeline from the given ast TODO see about moving this to ExecutionContext or PipelineExecutor, so that we can more easily go straight from AST to RealizedPipeline

    • getBuilder

      public getBuilder()
      a PipelineBuilder for constructing Pipelines TODO move to some sort of base pipeline change class?
    • getAnswer

      public Answer getAnswer()
      the Answer that resulted in this build state
    • getQuestionSet

      public QuestionSet getQuestionSet()
      the QuestionSet linked to this build state, e.g the question and answer belonged to this QuestionSet
    • getQuestion

      public Question getQuestion()
      the Question who's answer resulted in the build state
    • getProject

      public getProject()
      the Project associated with this build state
    • getAllAnswers

      public List<Answer> getAllAnswers()
      all that answers in the buildstate, in the order they were most recently given, i.e the head of the list is the same as this build state's getAnswer()
    • isQuestionSetAnswered

      public boolean isQuestionSetAnswered(String questionSetId)

      Determine whether a question set with the given id appears in this build state's change stack, indicating that the question set has been responded to or skipped

    • wasAsked

      public boolean wasAsked(String questionSetId, String questionName)

      Determine whether a question has been asked, regardless of whether the user provided a response or just chose to skip the question.

      This method accepts id strings, rather than the actual objects, to allow other questions to test for their presence without needing a reference to the other question

      true if the given question was answered, regardless of whether a response was given.
    • lastAnswerWas

      public boolean lastAnswerWas(Object value)

      Returns true if the last answer was the given value. This only checks the answer supplied for single-valued Questions, so it will always return false if the question is not single valued.

    • isResponseGiven

      public boolean isResponseGiven(String questionSetId, String questionName)

      Determine whether a response has been given to a question by its name local to the current question set.

      This method accepts id strings, rather than the actual objects, to allow other questions to test for their presence without needing a reference to the other question

      true if the given question was answered and at least one response was given.
    • ifResponseGiven

      public <T> boolean ifResponseGiven(String questionSetId, String questionName, Class<T> clazz, Consumer<T> callback)

      Functional style if that calls the callback if a response was given to the nominated question, returning true if the callback was called

    • getBindingContext

      public getBindingContext()
      the BindingContext associated with this pipeline build state's context
    • getPipelineExecutor

      public getPipelineExecutor()
      the PipelineExecutor associated with this pipeline build state's context
    • getSurvey

      public Survey getSurvey()
    • toString

      public String toString()
      toString in class Object
    • getContext

      public IncrementalBuildState.Context getContext()

      Various static dependencies, i.e. this is the same object for all members of the change stack

    • getLast

      public IncrementalBuildState getLast()

      The previous thing we built upon - will return this if this is the empty build state

    • getCreatedBy

      public PipelineChange getCreatedBy()

      The change that was responsible for this state being created

    • getAst

      public getAst()

      The current pipeline ast.

    • getRealizedPipeline

      public getRealizedPipeline()

      A small chunk of the overall pipeline that was realized for this state to be proven valid.

    • equals

      public boolean equals(Object o)
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      hashCode in class Object