O - Output typepublic class ResponseConsumer<O> extends java.lang.Object implements io.reactivex.functions.Consumer<Response<O>>
Consumer implementation for emissions of Response classes.
It simplifies differentiated handling of response scenarios applying a mechanism
to gracefully consume response success and response failures.
See Response.isSuccessful() for reference.
| Constructor and Description |
|---|
ResponseConsumer(io.reactivex.functions.Consumer<O> successConsumer)
Create a consumer which handles only success cases
|
ResponseConsumer(io.reactivex.functions.Consumer<O> successConsumer,
io.reactivex.functions.Consumer<Failure> failureConsumer)
Create a consumer to handle success and failure
cases of
Response class |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Response<O> response) |
static <O> ResponseConsumer<O> |
consume(io.reactivex.functions.Consumer<O> successConsumer,
io.reactivex.functions.Consumer<Failure> failureConsumer)
Factory method for consuming
Response success and failures. |
static <O> ResponseConsumer<O> |
consumeFailure(io.reactivex.functions.Consumer<Failure> failureConsumer)
Factory method for consuming
Response failure. |
static <O> ResponseConsumer<O> |
consumeSuccess(io.reactivex.functions.Consumer<O> successConsumer)
Factory method for consuming
Response success. |
public ResponseConsumer(io.reactivex.functions.Consumer<O> successConsumer)
successConsumer - Delegate consumerpublic ResponseConsumer(io.reactivex.functions.Consumer<O> successConsumer, io.reactivex.functions.Consumer<Failure> failureConsumer)
Response classsuccessConsumer - Delegate success consumerfailureConsumer - Delegate failure consumerpublic static <O> ResponseConsumer<O> consumeSuccess(io.reactivex.functions.Consumer<O> successConsumer)
Response success.
Failure will be ignored.O - Output typesuccessConsumer - Delegate success consumerpublic static <O> ResponseConsumer<O> consumeFailure(io.reactivex.functions.Consumer<Failure> failureConsumer)
Response failure.
Success will be ignored.O - Output typefailureConsumer - Delegate failure consumerpublic static <O> ResponseConsumer<O> consume(io.reactivex.functions.Consumer<O> successConsumer, io.reactivex.functions.Consumer<Failure> failureConsumer)
Response success and failures.O - Output typesuccessConsumer - Delegate success consumerfailureConsumer - Delegate failure consumer