public static class FluentFunctions.FluentFunction<T,R> extends java.lang.Object implements java.util.function.Function<T,R>, Reader<T,R>
Constructor and Description |
---|
FluentFunction(java.util.function.Function<T,R> fn) |
Modifier and Type | Method and Description |
---|---|
FluentFunctions.FluentFunction<T,R> |
after(java.util.function.BiConsumer<T,R> action)
Apply After advice to this function capturing both the input and the output with the provided BiConsumer
|
<V> java.util.function.Function<T,V> |
andThen(java.util.function.Function<? super R,? extends V> after) |
R |
apply(T t) |
FluentFunctions.FluentFunction<T,R> |
around(java.util.function.Function<FluentFunctions.Advice1<T,R>,R> around)
Apply around advice to this function, captures input allows output to be controlled by the advice
|
java.util.concurrent.CompletableFuture<FluentFunctions.FluentFunction<T,R>> |
async(java.util.concurrent.Executor ex)
Move this function into an asynchronous context
|
FluentFunctions.FluentFunction<T,R> |
before(java.util.function.Consumer<T> action)
Apply before advice to this function, capture the input with the provided Consumer
|
<V> java.util.function.Function<V,R> |
compose(java.util.function.Function<? super V,? extends T> before) |
<R1> FluentFunctions.FluentFunction<T,R1> |
flatMap(java.util.function.Function<? super R,? extends Reader<T,R1>> f)
FlatMap this Reader by applying the prodived function and unnesting to a single Reader
|
ReactiveSeq<R> |
generate(T input) |
ReactiveSeq<R> |
iterate(T seed,
java.util.function.Function<R,T> mapToType)
Generate an infinite Stream that iterates from the specified seed using the currently wrapped function
e.g.
|
FluentFunctions.FluentFunction<java.util.Optional<T>,java.util.Optional<R>> |
lift() |
FluentFunctions.FluentFunction<T,java.util.concurrent.CompletableFuture<R>> |
liftAsync(java.util.concurrent.Executor ex) |
FluentFunctions.FluentFunction<AnyM<T>,AnyM<R>> |
liftM() |
<X extends java.lang.Throwable> |
liftTry(java.lang.Class<X>... classes) |
FluentFunctions.FluentFunction<T,R> |
log(java.util.function.Consumer<java.lang.String> logger,
java.util.function.Consumer<java.lang.Throwable> error)
A Function that logs it's success or error states to the provided Consumers
|
<R1> FluentFunctions.FluentFunction<T,R1> |
map(java.util.function.Function<? super R,? extends R1> f2)
Transform this functor using the supplied transformation function
|
<R1> FluentFunctions.FluentFunction<T,R1> |
matches(java.util.function.Function<Matchable.CheckValue1<R,R1>,Matchable.CheckValue1<R,R1>> case1,
java.util.function.Supplier<? extends R1> otherwise)
A Function that triggers an event if the result matches the case provided, or generates a new value from the supplier
provided if not
|
FluentFunctions.FluentFunction<T,R> |
memoize() |
FluentFunctions.FluentFunction<T,R> |
memoize(Cacheable<R> cache) |
FluentFunctions.FluentFunction<T,R> |
name(java.lang.String name) |
FluentFunctions.FluentSupplier<R> |
partiallyApply(T param)
Partially apply the provided value to this function, to turn it into a Supplier
|
FluentFunctions.FluentFunction<T,R> |
println() |
<X extends java.lang.Throwable> |
recover(java.lang.Class<X> type,
java.util.function.Function<T,R> onError)
A Function that can recover from the specified exception types, using the provided recovery Function
|
FluentFunctions.FluentFunction<T,R> |
retry(int times,
int backoffStartTime)
A Function capable of retrying on failure using an exponential backoff strategy
|
FluentFunctions.FluentFunction<T,R> |
visitEvent(java.util.function.Consumer<R> eventConsumer,
java.util.function.Consumer<java.lang.Throwable> errorConsumer)
Visit the result of this Function once it has been executed, if the Function executes successfully the
result will be passes to the eventConsumer, if there is an error it will be passed to the errorConsumer
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cast, patternMatch, peek, trampoline
public <R1> FluentFunctions.FluentFunction<T,R1> map(java.util.function.Function<? super R,? extends R1> f2)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
public <R1> FluentFunctions.FluentFunction<T,R1> flatMap(java.util.function.Function<? super R,? extends Reader<T,R1>> f)
Reader
public FluentFunctions.FluentFunction<T,R> before(java.util.function.Consumer<T> action)
action
- Before advicepublic FluentFunctions.FluentFunction<T,R> after(java.util.function.BiConsumer<T,R> action)
action
- After advicepublic FluentFunctions.FluentFunction<T,R> around(java.util.function.Function<FluentFunctions.Advice1<T,R>,R> around)
around
- Around advicepublic FluentFunctions.FluentSupplier<R> partiallyApply(T param)
param
- Input param to apply to this functionpublic FluentFunctions.FluentFunction<T,R> memoize()
public FluentFunctions.FluentFunction<T,R> memoize(Cacheable<R> cache)
cache
- A wrapper around an external cache implementationpublic FluentFunctions.FluentFunction<T,R> name(java.lang.String name)
name
- To give this Functionpublic FluentFunctions.FluentFunction<T,R> log(java.util.function.Consumer<java.lang.String> logger, java.util.function.Consumer<java.lang.Throwable> error)
logger
- Success loggererror
- Failure loggerpublic FluentFunctions.FluentFunction<T,R> visitEvent(java.util.function.Consumer<R> eventConsumer, java.util.function.Consumer<java.lang.Throwable> errorConsumer)
eventConsumer
- Consumer to recieve result on successful executionerrorConsumer
- Consumer to recieve error on failurepublic FluentFunctions.FluentFunction<T,R> println()
public <X extends java.lang.Throwable> FluentFunctions.FluentFunction<T,R> recover(java.lang.Class<X> type, java.util.function.Function<T,R> onError)
type
- Recoverable exception typesonError
- Recovery functionpublic FluentFunctions.FluentFunction<T,R> retry(int times, int backoffStartTime)
times
- Number of times to retrybackoffStartTime
- Wait time before first retrypublic <R1> FluentFunctions.FluentFunction<T,R1> matches(java.util.function.Function<Matchable.CheckValue1<R,R1>,Matchable.CheckValue1<R,R1>> case1, java.util.function.Supplier<? extends R1> otherwise)
case1
- Case against which the value returned by this Function will be comparedotherwise
- Supplier to generate an alterantive value if this value does not match the provided casepublic ReactiveSeq<R> iterate(T seed, java.util.function.Function<R,T> mapToType)
FluentFunctions.of(this::addOne)
.iterate(95281,i->i)
.forEach(System.out::println);
//95282
//95283
//95284
//95285
//95286
//etc
seed
- initial valuemapToType
- Convert from supplied functions return type to Stream input typepublic ReactiveSeq<R> generate(T input)
input
- Input value, this function will applied to this value to generate the value that will be infinitely repeated in this StreamReactiveSeq
of values determined by the application
of this function to the input valuepublic FluentFunctions.FluentFunction<java.util.Optional<T>,java.util.Optional<R>> lift()
public <X extends java.lang.Throwable> FluentFunctions.FluentFunction<T,Try<R,X>> liftTry(java.lang.Class<X>... classes)
classes
- To catch exceptions forpublic FluentFunctions.FluentFunction<AnyM<T>,AnyM<R>> liftM()
public FluentFunctions.FluentFunction<T,java.util.concurrent.CompletableFuture<R>> liftAsync(java.util.concurrent.Executor ex)
ex
- Executor to execute this function onpublic java.util.concurrent.CompletableFuture<FluentFunctions.FluentFunction<T,R>> async(java.util.concurrent.Executor ex)
ex
- Executor to manage operations on this function onpublic <V> java.util.function.Function<V,R> compose(java.util.function.Function<? super V,? extends T> before)