Class RealizedStep

java.lang.Object
nz.org.riskscape.engine.pipeline.RealizedStep
All Implemented Interfaces:
AutoCloseable

public class RealizedStep extends Object implements AutoCloseable

A Step that has been realized, such that it has produced valid output. A RealizedStep is a linked traversable DAG in itself, and so is a sort of realized Pipeline whose outputs can be used.

  • Constructor Details

    • RealizedStep

      public RealizedStep(String name, @NonNull @NonNull Step implementation, StepDefinition ast, @NonNull @NonNull ResultOrProblems<? extends Realized> result, @NonNull @NonNull Map<String,List<?>> boundParameters, @NonNull @NonNull List<RealizedStep> dependencies, @NonNull @NonNull Struct produces)

      Creates a new RealizedStep instance.

      Parameters:
      name - The name that was assigned to this step - unique within the pipeline
      implementation - The Step that produced a realized output that went in to this RealizedStep
      ast - The part of the syntax tree that defined this step
      result - The output of the step. TODO drop the ResultOrProblems?
      boundParameters - The complete set of Parameters that were used to realize this step.
      dependencies - The complete set of RealizedSteps that were used to realize this step
      produces -
  • Method Details

    • emptyInput

      public static RealizedStep emptyInput(String name, Struct type)
      Returns:
      a RealizedStep useful for testing scenarios where you want to test realization of some pipeline bits appended to something
    • named

      public static RealizedStep named(String named)
      Returns:
      a RealizedStep with a name and nothing else
    • fromInput

      public static RealizedStep fromInput(RealizationInput input)
      Returns:
      a RealizedStep with name, ast, parameters, and dependencies set from the given realization input (but not the Realized object and its type)
    • isFailed

      public boolean isFailed()
      Returns:
      true if this step or a dependency failed
    • isDirectlyFailed

      public boolean isDirectlyFailed()
      Returns:
      true if this step failed, but not if that failure was because of a dependency
    • hasDependencies

      public boolean hasDependencies()
      Returns:
      true if this step has any direct dependencies
    • hasNoDependencies

      public boolean hasNoDependencies()
      Returns:
      false if this step has any direct dependenices
    • getName

      public String getName()
      Returns:
      the name assigned to this step, either explicitly in the AST, or a generated one based on the StepNamingPolicy
    • getStepName

      public String getStepName()
    • toString

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

      public Optional<Problem> getFailureProblem()
      Returns:
      a composite problem for all errors associated with realizing this step, or empty if there were no errors
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getStepType

      public Class<? extends Realized> getStepType()
    • getRealized

      public <T extends Realized> Optional<T> getRealized(Class<T> stepType)

      Returns the realized result of this step, cast to a given type. Mostly useful for internal workings where the step is assumed to be of a specific type, as it deals in Optionals, not ResultOrProblems

      Parameters:
      stepType - The type of the result
      Returns:
      The realized result, or empty if this step failed to realize, or if the step isn't of the given step type
    • getProblems

      public List<Problem> getProblems()
      Returns:
      a list of problems from the attempt to realize this step, or an empty list if it didn't have problems during realization
    • withProblems

      public RealizedStep withProblems(Problem... problems)

      Convenience version of withProblems(List)

    • withProblems

      public RealizedStep withProblems(List<Problem> problems)

      Clones this RealizedStep with only given problems, marking it as failed if problem list has errors

    • realizedBy

      public RealizedStep realizedBy(Step step)

      Clone this step, setting the Step implementation that realized it.

    • withResult

      public RealizedStep withResult(ResultOrProblems<? extends Realized> realizedOr)

      Clone this step, replacing the realized result and setting the produced type to be from that result as well (setting it to the empty struct if it's failed)

    • withResult

      public RealizedStep withResult(Realized realized)

      Clone this step, replacing the realized result and setting the produced type to be from that result as well

    • withResult

      public RealizedStep withResult(Realized realized, Struct newType)

      Clone this step, replacing the result and realized type

    • withName

      public RealizedStep withName(String newName)

      Clone this step, giving it a new name

    • withDependencies

      public RealizedStep withDependencies(RealizedStep... newDependencies)

      Convenience version of withDependencies(List)

    • withDependencies

      public RealizedStep withDependencies(List<RealizedStep> newDependencies)

      Clone this step, replacing the dependencies

    • withParameters

      public RealizedStep withParameters(Map<String,List<?>> newParams)

      Clone this step, replacing the parameters with the given ones

    • withAst

      public RealizedStep withAst(StepDefinition defn)

      Clone this step, replacing the StepDefinition that is said to have realized this step.

    • getImplementation

      @NonNull public @NonNull Step getImplementation()

      The Step that produced a realized output that went in to this RealizedStep

    • getAst

      public StepDefinition getAst()

      The part of the syntax tree that defined this step

    • getResult

      @NonNull public @NonNull ResultOrProblems<? extends Realized> getResult()

      The output of the step. TODO drop the ResultOrProblems?

    • getBoundParameters

      @NonNull public @NonNull Map<String,List<?>> getBoundParameters()

      The complete set of Parameters that were used to realize this step.

    • getDependencies

      @NonNull public @NonNull List<RealizedStep> getDependencies()

      The complete set of RealizedSteps that were used to realize this step

    • getProduces

      @NonNull public @NonNull Struct getProduces()
    • equals

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

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object