Interface Handlers<Case,Handler>

Type Parameters:
Case - the type of the case
Handler - the type of the handler

public interface Handlers<Case,Handler>
Handler registry - gives possibility of registering handlers for specific cases and contexts. Also, it gives various ways of retrieving handlers.
Since:
4.2.1
Author:
Sara Pellegrini, Milan Savic
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String context, Case requestCase)
    Gets all handlers that match given context and requestCase.
    getOrDefault(String context, Case requestCase, Collection<Handler> def)
    The same as get(String, Object) but if no handler is found it returns provided def collection of handlers.
    default void
    register(Case requestCase, Handler handler)
    Registers a handler that can handle instructions for given requestCase regardless of context.
    default void
    register(Handler handler)
    Registers a handler that can handle instructions regardless of context or request case.
    default void
    register(String context, Case requestCase, Handler handler)
    Registers a handler that can handle instructions for given context and requestCase.
    default void
    register(String context, Handler handler)
    Registers a handler that can handle instructions for given context regardless of request case.
    void
    register(BiPredicate<String,Case> handlerSelector, Handler handler)
    Registers a handler that can handle instructions matching given handlerSelector predicate.
  • Method Details

    • get

      Collection<Handler> get(String context, Case requestCase)
      Gets all handlers that match given context and requestCase.
      Parameters:
      context - the context
      requestCase - the type of instruction to respond to
      Returns:
      collection of corresponding handlers
    • getOrDefault

      default Collection<Handler> getOrDefault(String context, Case requestCase, Collection<Handler> def)
      The same as get(String, Object) but if no handler is found it returns provided def collection of handlers.
      Parameters:
      context - the context
      requestCase - the type of instruction to respond to
      def - the default handlers if this registry does not contain any matching given criteria
      Returns:
      collection of corresponding handlers
    • register

      default void register(Handler handler)
      Registers a handler that can handle instructions regardless of context or request case.
      Parameters:
      handler - the handler of the instruction
    • register

      default void register(String context, Handler handler)
      Registers a handler that can handle instructions for given context regardless of request case.
      Parameters:
      context - the context
      handler - the handler of the instruction
    • register

      default void register(Case requestCase, Handler handler)
      Registers a handler that can handle instructions for given requestCase regardless of context.
      Parameters:
      requestCase - the type of instruction to respond to
      handler - the handler of the instruction
    • register

      default void register(String context, Case requestCase, Handler handler)
      Registers a handler that can handle instructions for given context and requestCase.
      Parameters:
      context - the context
      requestCase - the type of instruction to respond to
      handler - the handler of the instruction
    • register

      void register(BiPredicate<String,Case> handlerSelector, Handler handler)
      Registers a handler that can handle instructions matching given handlerSelector predicate.
      Parameters:
      handlerSelector - selects a handler based on context and request case
      handler - the handler of the instruction