Class StepExecutor

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.tooluser.stepexecutor.StepExecutor
Direct Known Subclasses:
AsyncStepExecutor, StepExecutorBoolean, StepExecutorInteger, StepExecutorLocation, StepExecutorOpenDirection, StepExecutorString, StepExecutorVector3Di, StepExecutorVoid

public abstract class StepExecutor extends Object
Represents an executor for a single step in a larger procedure.
  • Constructor Details

    • StepExecutor

      public StepExecutor()
  • Method Details

    • apply

      public final CompletableFuture<Boolean> apply(@Nullable Object input) throws IllegalArgumentException
      Applies an object to the function defined for this step.

      While this method returns a CompletableFuture, it is not guaranteed to be asynchronous. If the step is synchronous, it will return a completed future.

      Parameters:
      input - The object to give to the provided function.
      Throws:
      IllegalArgumentException - If the input object is not of the expected type.
    • protectedAccept

      protected boolean protectedAccept(@Nullable Object obj)
      Protected version of apply(Object). That method takes care of input type verification.

      This method should be overridden by subclasses that are synchronous.

      Parameters:
      obj - The object to process in this step.
    • protectedAcceptAsync

      protected CompletableFuture<Boolean> protectedAcceptAsync(@Nullable Object obj)
      Protected version of protectedAccept(Object). That method takes care of input type verification.

      This method should be overridden by subclasses that are asynchronous.

      Parameters:
      obj - The object to give to the BiFunction.
    • validInput

      public boolean validInput(@Nullable Object obj)
      Checks if an object is a valid input type.
      Parameters:
      obj - The object to check.
      Returns:
      True if this object is valid for the current type.
    • getInputClass

      protected abstract Class<?> getInputClass()
      Checks the type that is expected as input for this step.
      Returns:
      The Class of the input object.
    • isAsync

      public boolean isAsync()
      Checks if this step is asynchronous.
      Returns:
      True if this step is asynchronous.
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object