Class ResultedProcess<T>

java.lang.Object
com.mrivanplays.process.ResultedProcess<T>
Type Parameters:
T - result value type parameter

public abstract class ResultedProcess<T> extends Object
Represents a Process that has a result.
Since:
0.0.1
Author:
Ivan Pekov
  • Constructor Details

    • ResultedProcess

      public ResultedProcess(String identifier)
      Base constructor for all ResultedProcess implementations.
      Parameters:
      identifier - the identifier of this resulted process. It is good to set it every time implementation class(es) are created in order to properly defer results.
  • Method Details

    • fromSupplier

      public static <T> ResultedProcess<T> fromSupplier(String identifier, Supplier<T> supplier)
      Creates a new ResultedProcess from a Supplier
      Type Parameters:
      T - result value type parameter
      Parameters:
      identifier - resulted process identifier
      supplier - input supplier
      Returns:
      resulted process
    • run

      protected abstract T run() throws Throwable
      Main logic for running the process
      Returns:
      a non null result value
      Throws:
      Throwable - if anything goes wrong, the implementation can throw any exception.