Class Actions<T>

java.lang.Object
one.tranic.t.base.task.Actions<T>
Type Parameters:
T - the type of the result produced by the encapsulated task

public class Actions<T> extends Object
Represents a wrapper for executing tasks either synchronously or asynchronously.

This class encapsulates a task defined by a Supplier, offering methods for immediate execution or deferred execution using a shared executor.

  • Constructor Details

    • Actions

      public Actions(Supplier<T> task)
      Constructs a new Actions instance with the specified task.
      Parameters:
      task - the Supplier representing the task to be executed
  • Method Details

    • sync

      public T sync()
      Executes the encapsulated task synchronously and returns its result.
      Returns:
      the result produced by the encapsulated task
    • async

      public CompletableFuture<T> async()
      Executes the encapsulated task asynchronously using a shared executor.
      Returns:
      a CompletableFuture<T> that completes with the result of the asynchronous task execution