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
Listener
s that match the request are executed, even if you only send for a single result - The order in which the
Listener
s 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
Listener
s - If exactly one of the
Listener
s throws aThrowable
, then thatThrowable
is thrown - If multiple
Listener
s throw aThrowable
, then aMultipleThrowablesOccurredException
is thrown, containing all theThrowable
s that were thrown - If any method parameter is 'null', then an
IllegalArgumentException
is thrown (null values may occur in the 'parameters' varargs array, however)
- Author:
- G.J. Schouten
-
Method Summary
Modifier and TypeMethodDescription<T> T
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.<T> Collection
<T> sendForMultipleOfClass
(Class<T> returnType, Object... parameters) Send a request to allListener
s that satisfy the following requirements.<T> Collection
<T> sendForMultipleOfClassWithHint
(Class<T> returnType, String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.<T> Collection
<T> sendForMultipleWithHint
(String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.void
sendForNothing
(Object... parameters) Send a request to allListener
s that satisfy the following requirements.void
sendForNothingWithHint
(String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.<T> T
sendForSingleOfClass
(Class<T> returnType, Object... parameters) Send a request to allListener
s that satisfy the following requirements.<T> T
sendForSingleOfClassWithHint
(Class<T> returnType, String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.<T> T
sendForSingleWithHint
(String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.
-
Method Details
-
sendForSingleOfClass
Send a request to allListener
s that satisfy the following requirements.- They return an
Object
that 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 theListener
sparameters
- the parameters to give to theListener
s- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listener
s were found
- They return an
-
sendForMultipleOfClass
Send a request to allListener
s that satisfy the following requirements.- They return an
Object
that the parameter 'returnType' is assignable from and - they belong to a method with parameters that match the given 'parameters' objects
Listener
s that are executed may be larger than the number of return values that is returned, because someListener
s may return nothing (void).- Parameters:
returnType
- the return type that has to be assignable from the return type of theListener
sparameters
- the parameters to give to theListener
s- Returns:
- all return values from the listeners that executed or an empty
Collection
if no matchingListener
s were found. This method never returns null.
- They return an
-
sendForNothing
Send a request to allListener
s 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 theListener
s
-
sendForSingleWithHint
Send a request to allListener
s 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 theListener
sparameters
- the parameters to give to theListener
s- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listener
s were found or none of them returned anything
-
sendForMultipleWithHint
Send a request to allListener
s 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
Listener
s that are executed may be larger than the number of return values that is returned, because someListener
s may return nothing (void).- Parameters:
hint
- the hint that has to be equal to the hint of theListener
sparameters
- the parameters to give to theListener
s- Returns:
- all return values from the listeners that executed or an empty
Collection
if no matchingListener
s were found or none of them returned anything. This method never returns null.
-
sendForNothingWithHint
Send a request to allListener
s 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 allListener
s that satisfy the following requirements.- They return an
Object
that 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 theListener
shint
- the hint that has to be equal to the hint of theListener
sparameters
- the parameters to give to theListener
s- Returns:
- a single return value from one of the listeners that executed (which one is unspecified) or 'null' if no matching
Listener
s were found
- They return an
-
sendForMultipleOfClassWithHint
<T> Collection<T> sendForMultipleOfClassWithHint(Class<T> returnType, String hint, Object... parameters) Send a request to allListener
s that satisfy the following requirements.- They return an
Object
that 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
Listener
s that are executed may be larger than the number of return values that is returned, because someListener
s may return nothing (void).- Parameters:
returnType
- the return type that has to be assignable from the return type of theListener
shint
- the hint that has to be equal to the hint of theListener
sparameters
- the parameters to give to theListener
s- Returns:
- all return values from the listeners that executed or an empty
Collection
if no matchingListener
s 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
-