public interface Transformers
Modifier and Type | Method and Description |
---|---|
static <IS,OS,F,OF extends F> |
attempt(Function<IS,Result<OS,OF>> mappingFunction)
Returns a function which takes a Result and, if it's a success, applies the provided function
to that success - generating a new Result - and returns that Result.
|
static <S,F> Function<Result<S,F>,Result<F,S>> |
invert()
Returns a function which takes a Result, and converts failures to successes and vice versa.
|
static <S,F> Function<Result<Result<S,F>,F>,Result<S,F>> |
mergeFailures()
Returns a function which takes a Result whose success type is itself a Result, and merges the failure cases
so we have a flat Result.
|
static <S,F1,F2> Function<Result<Result<S,F1>,F2>,Result<S,F1>> |
mergeFailures(Function<F2,F1> failureMapper)
Returns a function which takes a Result whose success type is itself a Result, and merges the failure cases
so we have a flat Result.
|
static <S,IF,OF> Function<Result<S,IF>,Result<S,OF>> |
onFailure(Function<IF,OF> mappingFunction)
Returns a function which takes a Result and, if it's a failure, applies the provided function
to that failure.
|
static <S,F> ConsumableFunction<Result<S,F>> |
onFailureDo(Consumer<F> consumer)
Returns a consumer which takes a Result and, if it's a failure, passes it to the provided consumer
|
static <IS,OS,F> Function<Result<IS,F>,Result<OS,F>> |
onSuccess(Function<IS,OS> mappingFunction)
Returns a function which takes a Result and, if it's a success, applies the mapping value to that
success, otherwise returning the original failure.
|
static <S,F> ConsumableFunction<Result<S,F>> |
onSuccessDo(Consumer<S> consumer)
Returns a Consumer which takes a Result and, if it's a Success, passes it to the provided consumer.
|
static <IS,OS,X extends Exception> |
onSuccessTry(ThrowingLambdas.ThrowingFunction<IS,OS,X> throwingFunction)
Returns a function which takes a Result with an Exception failure type and, if it's a success, applies
the mapping value to that success, returning a new success unless an exception is thrown, when it
returns a failure of that exception.
|
static <IS,OS,F,X extends Exception> |
onSuccessTry(ThrowingLambdas.ThrowingFunction<IS,OS,X> throwingFunction,
Function<Exception,F> exceptionMapper)
Returns a function which takes a Result and, if it's a success, applies the mapping value
to that success, returning a new success unless an exception is thrown, when it
returns a failure of the exception-mapper applied to the exception.
|
static <S,IF,OF,OS extends S> |
recover(Function<IF,Result<OS,OF>> recoveryFunction)
Returns a function which takes a Result and, if it's a failure, applies the provided function to
that failure - generating a new Result - and returns that Result.
|
static <S,F> Function<Result<Stream<S>,F>,Stream<Result<S,F>>> |
unwrapSuccesses()
Takes a Result of a Stream as a success or a single failure, and returns a Stream of Results
containing all the successes, or the single failure.
|
static <IS,OS,F> Function<Result<IS,F>,Result<OS,F>> onSuccess(Function<IS,OS> mappingFunction)
static <S,F> ConsumableFunction<Result<S,F>> onSuccessDo(Consumer<S> consumer)
static <IS,OS,X extends Exception> Function<Result<IS,Exception>,Result<OS,Exception>> onSuccessTry(ThrowingLambdas.ThrowingFunction<IS,OS,X> throwingFunction)
static <IS,OS,F,X extends Exception> Function<Result<IS,F>,Result<OS,F>> onSuccessTry(ThrowingLambdas.ThrowingFunction<IS,OS,X> throwingFunction, Function<Exception,F> exceptionMapper)
static <IS,OS,F,OF extends F> Function<Result<IS,F>,Result<OS,F>> attempt(Function<IS,Result<OS,OF>> mappingFunction)
static <S,IF,OF> Function<Result<S,IF>,Result<S,OF>> onFailure(Function<IF,OF> mappingFunction)
static <S,F> ConsumableFunction<Result<S,F>> onFailureDo(Consumer<F> consumer)
static <S,F> Function<Result<Stream<S>,F>,Stream<Result<S,F>>> unwrapSuccesses()
static <S,IF,OF,OS extends S> Function<Result<S,IF>,Result<S,OF>> recover(Function<IF,Result<OS,OF>> recoveryFunction)
static <S,F> Function<Result<S,F>,Result<F,S>> invert()
static <S,F> Function<Result<Result<S,F>,F>,Result<S,F>> mergeFailures()
static <S,F1,F2> Function<Result<Result<S,F1>,F2>,Result<S,F1>> mergeFailures(Function<F2,F1> failureMapper)
Copyright © 2018. All rights reserved.