public final class FailureConverter extends java.lang.Object implements UseCaseDecorator
Failure objects.
FailureException will always get mapped to a Failure.
If an exceptionMapper is defined, it will be used to map
all the other exceptions. Otherwise (or if it returns null failure for an
exception) the exception will be propagated down the stream.| Modifier and Type | Method and Description |
|---|---|
<I,O> io.reactivex.Observable<Response<O>> |
decorate(io.reactivex.Observable<Response<O>> origin,
Request<I> ignored)
Decorate the passed observable stream with additional functionality.
|
static FailureConverter |
get(digital.bakehouse.rxusecase.decorator.FailureConverter.Mapper exceptionToFailureMapper)
Factory method to create a converter which converts the exceptions
emitted by the decorated use-cases into
Failure objects
using the passed mapper. |
static FailureConverter |
getDefault()
Factory method to create a converter which converts
only instances of the
FailureException into Failure
objects and propagates the other exception types does the stream. |
static FailureConverter |
getWithFallback(Failure fallbackFailure)
Factory method to create a converter which converts all
exceptions emitted by the decorated use-cases to
Failure objects:
- FailureException to their respective Failure objects
- any other exception to the passed fallback Failure |
public static FailureConverter getDefault()
FailureException into Failure
objects and propagates the other exception types does the stream.public static FailureConverter get(digital.bakehouse.rxusecase.decorator.FailureConverter.Mapper exceptionToFailureMapper)
Failure objects
using the passed mapper.exceptionToFailureMapper - Exception mapperpublic static FailureConverter getWithFallback(Failure fallbackFailure)
Failure objects:
- FailureException to their respective Failure objects
- any other exception to the passed fallback FailurefallbackFailure - Fallback failurepublic final <I,O> io.reactivex.Observable<Response<O>> decorate(io.reactivex.Observable<Response<O>> origin, Request<I> ignored)
UseCaseDecoratordecorate in interface UseCaseDecoratorI - Input typeO - Output typeorigin - Observable stream to decorateignored - Request object