Interface Handlers<Case,Handler>
- Type Parameters:
Case- the type of the caseHandler- 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 TypeMethodDescriptionGets all handlers that match givencontextandrequestCase.default Collection<Handler> getOrDefault(String context, Case requestCase, Collection<Handler> def) The same asget(String, Object)but if no handler is found it returns provideddefcollection of handlers.default voidRegisters ahandlerthat can handle instructions for givenrequestCaseregardless of context.default voidRegisters ahandlerthat can handle instructions regardless of context or request case.default voidRegisters ahandlerthat can handle instructions for givencontextandrequestCase.default voidRegisters ahandlerthat can handle instructions for givencontextregardless of request case.voidregister(BiPredicate<String, Case> handlerSelector, Handler handler) Registers ahandlerthat can handle instructions matching givenhandlerSelectorpredicate.
-
Method Details
-
get
Gets all handlers that match givencontextandrequestCase.- Parameters:
context- the contextrequestCase- the type of instruction to respond to- Returns:
- collection of corresponding handlers
-
getOrDefault
The same asget(String, Object)but if no handler is found it returns provideddefcollection of handlers.- Parameters:
context- the contextrequestCase- the type of instruction to respond todef- the default handlers if this registry does not contain any matching given criteria- Returns:
- collection of corresponding handlers
-
register
Registers ahandlerthat can handle instructions regardless of context or request case.- Parameters:
handler- the handler of the instruction
-
register
Registers ahandlerthat can handle instructions for givencontextregardless of request case.- Parameters:
context- the contexthandler- the handler of the instruction
-
register
Registers ahandlerthat can handle instructions for givenrequestCaseregardless of context.- Parameters:
requestCase- the type of instruction to respond tohandler- the handler of the instruction
-
register
Registers ahandlerthat can handle instructions for givencontextandrequestCase.- Parameters:
context- the contextrequestCase- the type of instruction to respond tohandler- the handler of the instruction
-
register
Registers ahandlerthat can handle instructions matching givenhandlerSelectorpredicate.- Parameters:
handlerSelector- selects a handler based on context and request casehandler- the handler of the instruction
-