Class StatefulHandler.StatefulHandlerInvoker

java.lang.Object
io.fluxzero.common.handling.HandlerInvoker.DelegatingHandlerInvoker
io.fluxzero.sdk.tracking.handling.StatefulHandler.StatefulHandlerInvoker
All Implemented Interfaces:
HandlerInvoker
Enclosing class:
StatefulHandler

protected class StatefulHandler.StatefulHandlerInvoker extends HandlerInvoker.DelegatingHandlerInvoker
  • Constructor Details

  • Method Details

    • invoke

      public Object invoke(BiFunction<Object,Object,Object> combiner)
      Description copied from interface: HandlerInvoker
      Invokes the handler and combines results using the given combiner function. Used when aggregating results from multiple invokers (e.g. HandlerInvoker.join(List)).
      Parameters:
      combiner - function to combine multiple results
      Returns:
      the combined result
    • handleResult

      protected void handleResult(Object result)
      Applies stateful persistence semantics to a handler invocation result.

      Supported result forms:

      • Collection<?>: stores every same-type instance in the collection. If the collection is empty, the current entry is deleted. If the current entry ID is not part of returned IDs, the current entry is deleted.
      • null: deletes the current entry only when the invoked method is expected to return handler state (same/assignable handler type).
      • Single object: stores it only if it is assignable to the handler type. If the stored ID differs from the current ID, the current entry is deleted (replacement behavior).
    • tryStoreResult

      protected Object tryStoreResult(Object result)
      Stores a result object if it is assignable to the stateful handler type.
      Parameters:
      result - object returned from a handler method
      Returns:
      the computed/stored handler ID, or null if the result is not a stateful handler instance
    • computeId

      protected Object computeId(Object handler)