Package org.elasticsearch.action
Class ActionListener.MappedActionListener<Response,MappedResponse>
java.lang.Object
org.elasticsearch.action.ActionListener.MappedActionListener<Response,MappedResponse>
- All Implemented Interfaces:
ActionListener<Response>
- Enclosing interface:
- ActionListener<Response>
public static final class ActionListener.MappedActionListener<Response,MappedResponse> extends java.lang.Object implements ActionListener<Response>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.action.ActionListener
ActionListener.MappedActionListener<Response,MappedResponse>
-
Method Summary
Modifier and Type Method Description <T> ActionListener<T>
map(org.elasticsearch.common.CheckedFunction<T,Response,java.lang.Exception> fn)
Creates a listener that wraps this listener, mapping response values via the given mapping function and passing along exceptions to this instance.void
onFailure(java.lang.Exception e)
A failure caused by an exception at some phase of the task.void
onResponse(Response response)
Handle action response.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
onResponse
Description copied from interface:ActionListener
Handle action response. This response may constitute a failure or a success but it is up to the listener to make that decision.- Specified by:
onResponse
in interfaceActionListener<Response>
-
onFailure
public void onFailure(java.lang.Exception e)Description copied from interface:ActionListener
A failure caused by an exception at some phase of the task.- Specified by:
onFailure
in interfaceActionListener<Response>
-
map
public <T> ActionListener<T> map(org.elasticsearch.common.CheckedFunction<T,Response,java.lang.Exception> fn)Description copied from interface:ActionListener
Creates a listener that wraps this listener, mapping response values via the given mapping function and passing along exceptions to this instance. Notice that it is considered a bug if the listener's onResponse or onFailure fails. onResponse failures will not call onFailure. If the function fails, the listener's onFailure handler will be called. The principle is that the mapped listener will handle exceptions from the mapping functionfn
but it is the responsibility ofdelegate
to handle its own exceptions inside `onResponse` and `onFailure`.- Specified by:
map
in interfaceActionListener<Response>
- Type Parameters:
T
- Response type of the wrapped listener- Parameters:
fn
- Function to apply to listener response- Returns:
- a listener that maps the received response and then passes it to this instance
-