Interface ActiveObject<T>

Type Parameters:
T - the type of the encapsulated instance

public interface ActiveObject<T>
Represents an active object that encapsulates its state and processes requests asynchronously.
Author:
Sergey Grachev
  • Method Details

    • getId

      Object getId()
      Returns a unique identifier for this active object.
      Returns:
      the ID of this active object
    • getInstance

      T getInstance()
      Returns the encapsulated instance managed by this active object.
      Returns:
      the encapsulated instance
    • get

      <R> CompletableFuture<R> get(AttributeGetter<T,R> action)
      Asynchronously retrieves an attribute from the encapsulated instance using the provided AttributeGetter.
      Type Parameters:
      R - the type of the attribute to get
      Parameters:
      action - the action that retrieves the attribute
      Returns:
      a CompletableFuture containing the retrieved attribute value
    • set

      <V> CompletableFuture<Void> set(AttributeSetter<T,V> action, @Nullable V value)
      Asynchronously sets an attribute in the encapsulated instance using the provided AttributeSetter.
      Type Parameters:
      V - the type of the attribute to set
      Parameters:
      action - the action that sets the attribute
      value - the new value for the attribute, or null if applicable
      Returns:
      a CompletableFuture indicating completion of the operation
    • setAndForget

      <V> void setAndForget(AttributeSetter<T,V> action, @Nullable V value)
      Asynchronously sets an attribute in the encapsulated instance using the provided AttributeSetter, without waiting for the operation to complete.
      Type Parameters:
      V - the type of the attribute to set
      Parameters:
      action - the action that sets the attribute
      value - the new value for the attribute, or null if applicable
    • invoke

      CompletableFuture<Void> invoke(Invoke<T> invoke)
      Asynchronously invokes a method on the encapsulated instance using the provided Invoke.
      Parameters:
      invoke - the invocation action to perform
      Returns:
      a CompletableFuture indicating completion of the operation
    • invokeAnForget

      void invokeAnForget(Invoke<T> invoke)
      Asynchronously invokes a method on the encapsulated instance using the provided Invoke, without waiting for the operation to complete.
      Parameters:
      invoke - the invocation action to perform
    • request

      <R> CompletableFuture<R> request(Object message)
      Asynchronously processes a request message, returning the result.
      Type Parameters:
      R - the type of the result
      Parameters:
      message - the request message to process
      Returns:
      a CompletableFuture containing the result of processing the request
    • requestAndForget

      void requestAndForget(Object message)
      Asynchronously processes a request message without waiting for the result.
      Parameters:
      message - the request message to process