Class FunctionModule

java.lang.Object
com.calebleavell.jatui.modules.TUIModule
com.calebleavell.jatui.modules.FunctionModule

public class FunctionModule extends TUIModule
Handles arbitrary logic execution for the application by executing a Supplier when the module is run. If tied to an ApplicationModule, whatever the supplier returns is updated in the app's inputMap and can be accessed via ApplicationModule.getInput(String).
  • Constructor Details

  • Method Details

    • doRunLogic

      public void doRunLogic()
      Runs the stored function, attempts to update the application input based on what the function returned, then runs children as provided by TUIModule.start()
      Specified by:
      doRunLogic in class TUIModule
    • getFunction

      public Supplier<?> getFunction()
      The function is the Supplier logic that this module will execute when it is run.
      Returns:
      The function stored by this module.
    • builder

      public static FunctionModule.Builder builder(String name, Supplier<?> function)
      Constructs a new FunctionModule builder.
      Parameters:
      name - The name of the builder.
      function - The Supplier that will be executed when this module is built and run.
      Returns:
      The new builder.
    • builder

      public static FunctionModule.Builder builder(String name, Runnable function)
      Constructs a new FunctionModule builder.
      Parameters:
      name - The name of the builder.
      function - The Runnable that will be executed when this module is built and run.
      Returns:
      The new builder.