Package org.rribbit
Interface RequestResponseBus
- All Known Implementing Classes:
DefaultRequestResponseBus
public interface RequestResponseBus
The bus to which requests can be sent and responses received. The following rules apply to all methods of this interface:
- When you send a request, ALL
Listeners that match the request are executed, even if you only send for a single result - The order in which the
Listeners are executed is not specified - The order in which the results are returned is not specified and does not necessarily match the execution order of the
Listeners - If exactly one of the
Listeners throws aThrowable, then thatThrowableis thrown - If multiple
Listeners throw aThrowable, then aMultipleThrowablesOccurredExceptionis thrown, containing all theThrowables that were thrown - If any method parameter is 'null', then an
IllegalArgumentExceptionis thrown (null values may occur in the 'parameters' varargs array, however)
- Author:
- G.J. Schouten
-
Method Summary
Modifier and TypeMethodDescription<T> TEquivalent tosendForSingleWithHint(String, Object...), since that is probably the most widely used method, because generally, when you know the hint, you know the returntype and you don't have to pass it specifically.<T> Collection<T> sendForMultipleOfClass(Class<T> returnType, Object... parameters) Send a request to allListeners that satisfy the following requirements.<T> Collection<T> sendForMultipleOfClassWithHint(Class<T> returnType, String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.<T> Collection<T> sendForMultipleWithHint(String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.voidsendForNothing(Object... parameters) Send a request to allListeners that satisfy the following requirements.voidsendForNothingWithHint(String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.<T> TsendForSingleOfClass(Class<T> returnType, Object... parameters) Send a request to allListeners that satisfy the following requirements.<T> TsendForSingleOfClassWithHint(Class<T> returnType, String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.<T> TsendForSingleWithHint(String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.
-
Method Details
-
sendForSingleOfClass
Send a request to allListeners that satisfy the following requirements.- They return an
Objectthat the parameter 'returnType' is assignable from and - they belong to a method with parameters that match the given 'parameters' objects
- Parameters:
returnType- the return type that has to be assignable from the return type of theListenersparameters- the parameters to give to theListeners- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listeners were found
- They return an
-
sendForMultipleOfClass
Send a request to allListeners that satisfy the following requirements.- They return an
Objectthat the parameter 'returnType' is assignable from and - they belong to a method with parameters that match the given 'parameters' objects
Listeners that are executed may be larger than the number of return values that is returned, because someListeners may return nothing (void).- Parameters:
returnType- the return type that has to be assignable from the return type of theListenersparameters- the parameters to give to theListeners- Returns:
- all return values from the listeners that executed or an empty
Collectionif no matchingListeners were found. This method never returns null.
- They return an
-
sendForNothing
Send a request to allListeners that satisfy the following requirements. Ignore all return values and return nothing.- They belong to a method with parameters that match the given 'parameters' objects
- Parameters:
parameters- the parameters to give to theListeners
-
sendForSingleWithHint
Send a request to allListeners that satisfy the following requirements.- They have a hint that is equals to the 'hint' parameter and
- they belong to a method with parameters that match the given 'parameters' objects
- Parameters:
hint- the hint that has to be equal to the hint of theListenersparameters- the parameters to give to theListeners- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listeners were found or none of them returned anything
-
sendForMultipleWithHint
Send a request to allListeners that satisfy the following requirements.- They have a hint that is equals to the 'hint' parameter and
- they belong to a method with parameters that match the given 'parameters' objects
Listeners that are executed may be larger than the number of return values that is returned, because someListeners may return nothing (void).- Parameters:
hint- the hint that has to be equal to the hint of theListenersparameters- the parameters to give to theListeners- Returns:
- all return values from the listeners that executed or an empty
Collectionif no matchingListeners were found or none of them returned anything. This method never returns null.
-
sendForNothingWithHint
Send a request to allListeners that satisfy the following requirements. Ignore all return values and return nothing.- They have a hint that is equals to the 'hint' parameter and
- they belong to a method with parameters that match the given 'parameters' objects
-
sendForSingleOfClassWithHint
Send a request to allListeners that satisfy the following requirements.- They return an
Objectthat the parameter 'returnType' is assignable from and - they have a hint that is equals to the 'hint' parameter and
- they belong to a method with parameters that match the given 'parameters' objects
- Parameters:
returnType- the return type that has to be assignable from the return type of theListenershint- the hint that has to be equal to the hint of theListenersparameters- the parameters to give to theListeners- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listeners were found
- They return an
-
sendForMultipleOfClassWithHint
<T> Collection<T> sendForMultipleOfClassWithHint(Class<T> returnType, String hint, Object... parameters) Send a request to allListeners that satisfy the following requirements.- They return an
Objectthat the parameter 'returnType' is assignable from and - they have a hint that is equals to the 'hint' parameter and
- they belong to a method with parameters that match the given 'parameters' objects
Listeners that are executed may be larger than the number of return values that is returned, because someListeners may return nothing (void).- Parameters:
returnType- the return type that has to be assignable from the return type of theListenershint- the hint that has to be equal to the hint of theListenersparameters- the parameters to give to theListeners- Returns:
- all return values from the listeners that executed or an empty
Collectionif no matchingListeners were found. This method never returns null.
- They return an
-
send
Equivalent tosendForSingleWithHint(String, Object...), since that is probably the most widely used method, because generally, when you know the hint, you know the returntype and you don't have to pass it specifically. This method is just a convenience shorthand method with a shorter name.- Parameters:
hint-parameters-- Returns:
- same as sendForSingleWithHint
-