T
- type data wrapped by the underlying monadpublic interface AnyM<T> extends Unwrapable, EmptyUnit<T>, Unit<T>, Foldable<T>, Functor<T>, FlatMap<T>, ToStream<T>
Modifier and Type | Interface and Description |
---|---|
static class |
AnyM.AnyMFactory |
Modifier and Type | Method and Description |
---|---|
AnyM<java.util.List<T>> |
aggregate(AnyM<T> next)
Aggregate the contents of this Monad and the supplied Monad
|
<R> AnyM<R> |
bind(java.util.function.Function<? super T,?> fn)
Perform a looser typed flatMap / bind operation
The return type can be another type other than the host type
Note the modified javaslang monad laws are not applied during the looser typed bind operation
The modification being used to work around the limits of the Java type system.
|
<R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Collect the contents of the monad wrapped by this AnyM into supplied collector
|
<T> AnyM<T> |
empty()
Construct an AnyM wrapping an empty instance of the wrapped type
e.g.
|
AnyM<T> |
filter(java.util.function.Predicate<? super T> p)
Perform a filter operation on the wrapped monad instance e.g.
|
<T1> AnyM<T1> |
flatten()
join / flatten one level of a nested hierarchy
|
static <T> AnyMSeq<T> |
fromArray(T... streamData)
Create an AnyM wrapping a Stream of the supplied data
|
static <T> AnyMSeq<T> |
fromCollection(java.util.Collection<T> collection)
Create an AnyM instance that wraps a Collection
|
static <T> AnyMValue<T> |
fromCompletableFuture(java.util.concurrent.CompletableFuture<T> future)
Create an AnyM instance that wraps a CompletableFuture
|
static AnyMSeq<java.lang.Double> |
fromDoubleStream(java.util.stream.DoubleStream stream)
Create an AnyM instance that wraps an DoubleStream
|
static <T> AnyMValue<T> |
fromEval(Eval<T> future) |
static <T> AnyMValue<T> |
fromFeatureToggle(FeatureToggle<T> future) |
static AnyMSeq<java.lang.String> |
fromFile(java.io.File file)
Create an AnyM instance that wraps an textual Stream from a file
|
static <T> AnyMValue<T> |
fromFutureW(FutureW<T> future) |
static AnyMSeq<java.lang.Integer> |
fromIntStream(java.util.stream.IntStream stream)
Create an AnyM instance that wraps an IntStream
|
static <T> AnyMValue<T> |
fromIor(Ior<?,T> future) |
static <T> AnyMSeq<T> |
fromIterable(java.lang.Iterable<T> iterable)
Create an AnyM instance that wraps an Iterable
|
static <T> AnyMSeq<T> |
fromList(java.util.List<T> list)
Create an AnyM from a List
This AnyM will convert the List to a Stream under the covers, but will rematerialize the Stream as List
if wrap() is called
|
static AnyMSeq<java.lang.Long> |
fromLongStream(java.util.stream.LongStream stream)
Create an AnyM instance that wraps an LongStream
|
static <T> AnyMValue<T> |
fromMaybe(Maybe<T> future) |
static <T> AnyMValue<T> |
fromOptional(java.util.Optional<T> optional)
Create an AnyM instance that wraps an Optional
|
static AnyMValue<java.lang.Double> |
fromOptionalDouble(java.util.OptionalDouble optional)
Create an AnyM instance that wraps an OptionalDouble
|
static AnyMValue<java.lang.Integer> |
fromOptionalInt(java.util.OptionalInt optional)
Create an AnyM instance that wraps an OptionalInt
|
static AnyMValue<java.lang.Long> |
fromOptionalLong(java.util.OptionalLong optional)
Create an AnyM instance that wraps an OptionalLong
|
static AnyMSeq<java.lang.Integer> |
fromRange(int start,
int end)
Construct an AnyM instance that wraps a range from start (inclusive) to end (exclusive) provided
The AnyM will contain a SequenceM over the spefied range
|
static AnyMSeq<java.lang.Long> |
fromRangeLong(long start,
long end)
Construct an AnyM instance that wraps a range from start (inclusive) to end (exclusive) provided
The AnyM will contain a SequenceM over the spefied range
|
static <T> AnyMSeq<T> |
fromSet(java.util.Set<T> set)
Create an AnyM from a Set
This AnyM will convert the Set to a Stream under the covers, but will rematerialize the Stream as Set
if wrap() is called
|
static <T> AnyMSeq<T> |
fromStream(java.util.stream.Stream<T> stream)
Create an AnyM instance that wraps a Stream
|
static <T> AnyMSeq<T> |
fromStreamable(ToStream<T> streamable)
Wrap a Streamable inside an AnyM
|
static <T> AnyMValue<T> |
fromTry(Try<T,?> future) |
static AnyMSeq<java.lang.String> |
fromURL(java.net.URL url)
Create an AnyM instance that wraps an textual Stream from a URL
|
static <T> AnyMValue<T> |
fromXor(Xor<?,T> future) |
static <U,R> java.util.function.Function<AnyM<U>,AnyM<R>> |
liftM(java.util.function.Function<? super U,? extends R> fn)
Lift a function so it accepts an AnyM and returns an AnyM (any monad)
AnyM view simplifies type related challenges.
|
static <U1,U2,R> java.util.function.BiFunction<AnyM<U1>,AnyM<U2>,AnyM<R>> |
liftM2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
Lift a function so it accepts a Monad and returns a Monad (simplex view of a wrapped Monad)
AnyM view simplifies type related challenges.
|
static <U1,U2,R> java.util.function.Function<AnyM<U1>,java.util.function.Function<AnyM<U2>,AnyM<R>>> |
liftM2(java.util.function.Function<U1,java.util.function.Function<U2,R>> fn)
Lift a Curried Function into Monadic form
|
static <U1,U2,U3,R> |
liftM3(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,? extends R>>> fn)
Lift a Curried Function into Monadic form
|
static <U1,U2,U3,R> |
liftM3(org.jooq.lambda.function.Function3<? super U1,? super U2,? super U3,? extends R> fn)
Lift a jOOλ Function3 into Monadic form.
|
static <U1,U2,U3,R> |
liftM3Cyclops(TriFunction<? super U1,? super U2,? super U3,? extends R> fn)
Lift a TriFunction into Monadic form.
|
static <U1,U2,U3,U4,R> |
liftM4(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,java.util.function.Function<? super U4,? extends R>>>> fn)
Lift a Curried Function into Monadic form
|
static <U1,U2,U3,U4,R> |
liftM4(org.jooq.lambda.function.Function4<? super U1,? super U2,? super U3,? super U4,? extends R> fn)
Lift a jOOλ Function4 into Monadic form.
|
static <U1,U2,U3,U4,R> |
liftM4Cyclops(QuadFunction<? super U1,? super U2,? super U3,? super U4,? extends R> fn)
Lift a QuadFunction into Monadic form.
|
static <U1,U2,U3,U4,U5,R> |
liftM5(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,java.util.function.Function<? super U4,java.util.function.Function<? super U5,? extends R>>>>> fn)
Lift a Curried Function
(5 levels a->b->c->d->e->fn.apply(a,b,c,d,e) ) into Monadic form |
static <U1,U2,U3,U4,U5,R> |
liftM5(org.jooq.lambda.function.Function5<? super U1,? super U2,? super U3,? super U4,? super U5,? extends R> fn)
Lift a jOOλ Function5 (5 parameters) into Monadic form
|
static <U1,U2,U3,U4,U5,R> |
liftM5Cyclops(QuintFunction<? super U1,? super U2,? super U3,? super U4,? super U5,? extends R> fn)
Lift a QuintFunction (5 parameters) into Monadic form
|
static <T> java.util.List<AnyMSeq<T>> |
listFromCollection(java.lang.Iterable<java.util.Collection<T>> anyM)
Take an iterable containing Streamables and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMValue<T>> |
listFromCompletableFuture(java.lang.Iterable<java.util.concurrent.CompletableFuture<T>> anyM)
Take an iterable containing CompletableFutures and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMValue<T>> |
listFromEval(java.lang.Iterable<Eval<T>> anyM) |
static <T> java.util.List<AnyMValue<T>> |
listFromFutureW(java.lang.Iterable<FutureW<T>> anyM) |
static <ST,T> java.util.List<AnyMValue<T>> |
listFromIor(java.lang.Iterable<Ior<ST,T>> anyM) |
static <T> java.util.List<AnyMSeq<T>> |
listFromIterable(java.lang.Iterable<java.lang.Iterable<T>> anyM)
Take an iterable containing Streamables and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMSeq<T>> |
listFromIterator(java.lang.Iterable<java.util.Iterator<T>> anyM)
Take an iterable containing Streamables and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMValue<T>> |
listFromMaybe(java.lang.Iterable<Maybe<T>> anyM) |
static <T> java.util.List<AnyMValue<T>> |
listFromOptional(java.lang.Iterable<java.util.Optional<T>> anyM)
Take an iterable containing Optionals and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMSeq<T>> |
listFromStream(java.lang.Iterable<java.util.stream.Stream<T>> anyM)
Take an iterable containing Streams and convert them into a List of AnyMs
e.g.
|
static <T> java.util.List<AnyMSeq<T>> |
listFromStreamable(java.lang.Iterable<Streamable<T>> anyM)
Take an iterable containing Streamables and convert them into a List of AnyMs
e.g.
|
static <ST,T> java.util.List<AnyMValue<T>> |
listFromXor(java.lang.Iterable<Xor<ST,T>> anyM) |
<R> AnyM<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Perform a map operation on the wrapped monad instance e.g.
|
Xor<AnyMValue<T>,AnyMSeq<T>> |
matchable() |
static <T> AnyM<T> |
ofConvertableSeq(java.lang.Object monad) |
static <T> AnyM<T> |
ofConvertableValue(java.lang.Object monad)
Take the supplied object and always attempt to convert it to a Monad type
|
static <T> AnyMValue<T> |
ofNullable(java.lang.Object nullable)
Generate an AnyM that wraps an Optional from the provided nullable object
|
static <T> AnyMSeq<T> |
ofSeq(java.lang.Object monad) |
static <T> AnyMValue<T> |
ofValue(java.lang.Object monad) |
AnyM<T> |
peek(java.util.function.Consumer<? super T> c)
Perform a peek operation on the wrapped monad e.g.
|
AnyMSeq<T> |
reduceMSeq(Monoid<AnyMSeq<T>> reducer) |
AnyMValue<T> |
reduceMValue(Monoid<AnyMValue<T>> reducer)
Perform a reduction using a Monoid that combines AnyM types.
|
static <T1> AnyMValue<ListX<T1>> |
sequence(java.util.Collection<? extends AnyM<T1>> seq)
Convert a Collection of Monads to a Monad with a List
|
static <T1> AnyMValue<ListX<T1>> |
sequence(java.util.stream.Stream<? extends AnyM<T1>> seq)
Convert a Stream of Monads to a Monad with a List
|
ReactiveSeq<T> |
stream() |
static <T> AnyMSeq<T> |
streamOf(T... streamData)
Create an AnyM wrapping a Stream of the supplied data
Identical to fromArray, exists as it may appear functionally more obvious to users than fromArray (which fits the convention)
|
<NT> ReactiveSeq<NT> |
toSequence(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends NT>> fn)
Sequence the contents of a Monad.
|
java.lang.String |
toString() |
static <T,R> AnyMValue<ListX<R>> |
traverse(java.util.Collection<? extends AnyM<T>> seq,
java.util.function.Function<? super T,? extends R> fn)
Convert a Collection of Monads to a Monad with a List applying the supplied function in the process
|
static <T,R> AnyMValue<ListX<R>> |
traverse(java.util.stream.Stream<? extends AnyM<T>> seq,
java.util.function.Function<? super T,? extends R> fn)
Convert a Stream of Monads to a Monad with a List applying the supplied function in the process
|
<T> AnyM<T> |
unit(T value)
Construct a new instanceof AnyM using the type of the underlying wrapped monad
|
<R> R |
unwrap() |
foldRight, foldRight, foldRight, foldRightMapToType, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce
cast, patternMatch, trampoline
getStreamable, isEmpty, iterator, jdkStream, reactiveSeq, reveresedJDKStream, reveresedStream
<R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
ReactiveSeq<T> stream()
<NT> ReactiveSeq<NT> toSequence(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends NT>> fn)
Optional<List<Integer>> into Stream<Integer>
List<Integer> list = AnyM.fromOptional(Optional.of(Arrays.asList(1,2,3,4,5,6)))
.<Integer>toSequence(c->c.stream())
.collect(Collectors.toList());
assertThat(list,hasItems(1,2,3,4,5,6));
<R> R unwrap()
unwrap
in interface Unwrapable
AnyM<T> filter(java.util.function.Predicate<? super T> p)
AnyM.fromOptional(Optional.of(10)).filter(i->i<10);
//AnyM[Optional.empty()]
AnyM.fromStream(Stream.of(5,10)).filter(i->i<10);
//AnyM[Stream[5]]
p
- Filtering predicate<R> AnyM<R> map(java.util.function.Function<? super T,? extends R> fn)
AnyM.fromIterable(Try.runWithCatch(this::loadData))
.map(data->transform(data))
AnyM.fromStream(Stream.of(1,2,3))
.map(i->i+2);
AnyM[Stream[3,4,5]]
AnyM<T> peek(java.util.function.Consumer<? super T> c)
AnyM.fromCompletableFuture(CompletableFuture.supplyAsync(()->loadData())
.peek(System.out::println)
<R> AnyM<R> bind(java.util.function.Function<? super T,?> fn)
AnyM<List<Integer>> m = AnyM.fromStream(Stream.of(Arrays.asList(1,2,3),Arrays.asList(1,2,3)));
AnyM<Integer> intM = m.bind(Collection::stream);
fn
- flatMap function<T1> AnyM<T1> flatten()
AnyM<java.util.List<T>> aggregate(AnyM<T> next)
AnyM.fromStream(Stream.of(1,2,3,4))
.aggregate(anyM(Optional.of(5)))
AnyM[Stream[List[1,2,3,4,5]]
List<Integer> result = AnyM.fromStream(Stream.of(1,2,3,4))
.aggregate(anyM(Optional.of(5)))
.toSequence()
.flatten()
.toList();
assertThat(result,equalTo(Arrays.asList(1,2,3,4,5)));
next
- Monad to aggregate content with<T> AnyM<T> unit(T value)
AnyM<Integer> ints = AnyM.fromList(Arrays.asList(1,2,3);
AnyM<String> string = ints.unit("hello");
<T> AnyM<T> empty()
Any<Integer> ints = AnyM.fromStream(Stream.of(1,2,3));
AnyM<Integer> empty=ints.empty();
AnyMValue<T> reduceMValue(Monoid<AnyMValue<T>> reducer)
Monoid<AnyMValue<Integer>> optionalAdd = Monoid.of(AnyM.fromOptional(Optional.of(0)), (a,b)-> AnyM.fromOptional(Optional.of(a.get()+b.get())));
AnyM.fromStream(Stream.of(2,8,3,1)).reduceM(optionalAdd);
//AnyM[Optional(14)];
reducer
- An identity value (approx. a seed) and BiFunction with a single type to reduce this anyMjava.lang.String toString()
toString
in class java.lang.Object
static AnyMSeq<java.lang.Integer> fromRange(int start, int end)
start
- Inclusive start of the rangeend
- Exclusive end of the rangestatic AnyMSeq<java.lang.Long> fromRangeLong(long start, long end)
start
- Inclusive start of the rangeend
- Exclusive end of the rangestatic <T> AnyMSeq<T> fromStreamable(ToStream<T> streamable)
streamable
- wrapstatic <T> AnyMSeq<T> fromList(java.util.List<T> list)
list
- to wrap inside an AnyMstatic <T> AnyMSeq<T> fromSet(java.util.Set<T> set)
list
- to wrap inside an AnyMstatic <T> AnyMSeq<T> fromArray(T... streamData)
streamData
- values to populate a Streamstatic <T> AnyMSeq<T> streamOf(T... streamData)
streamData
- values to populate a Streamstatic <T> AnyMSeq<T> fromStream(java.util.stream.Stream<T> stream)
stream
- Stream to wrapstatic AnyMSeq<java.lang.Integer> fromIntStream(java.util.stream.IntStream stream)
stream
- IntStream to wrapstatic AnyMSeq<java.lang.Double> fromDoubleStream(java.util.stream.DoubleStream stream)
stream
- DoubleStream to wrapstatic AnyMSeq<java.lang.Long> fromLongStream(java.util.stream.LongStream stream)
stream
- LongStream to wrapstatic <T> AnyMValue<T> fromOptional(java.util.Optional<T> optional)
stream
- Optional to wrapstatic AnyMValue<java.lang.Double> fromOptionalDouble(java.util.OptionalDouble optional)
stream
- Optional to wrapstatic AnyMValue<java.lang.Long> fromOptionalLong(java.util.OptionalLong optional)
stream
- OptionalLong to wrapstatic AnyMValue<java.lang.Integer> fromOptionalInt(java.util.OptionalInt optional)
stream
- OptionalInt to wrapstatic <T> AnyMValue<T> fromCompletableFuture(java.util.concurrent.CompletableFuture<T> future)
stream
- CompletableFuture to wrapstatic <T> AnyMValue<T> fromFeatureToggle(FeatureToggle<T> future)
static <T> AnyMSeq<T> fromCollection(java.util.Collection<T> collection)
stream
- Collection to wrapstatic <T> AnyMSeq<T> fromIterable(java.lang.Iterable<T> iterable)
stream
- Iterable to wrapstatic AnyMSeq<java.lang.String> fromFile(java.io.File file)
stream
- File to generate text / line Stream from, and to wrapstatic AnyMSeq<java.lang.String> fromURL(java.net.URL url)
stream
- URL to generate text / line Stream from, and to wrapstatic <T> AnyM<T> ofConvertableValue(java.lang.Object monad)
monad
- static <T> AnyM<T> ofConvertableSeq(java.lang.Object monad)
static <T> AnyMValue<T> ofValue(java.lang.Object monad)
static <T> AnyMSeq<T> ofSeq(java.lang.Object monad)
static <T> AnyMValue<T> ofNullable(java.lang.Object nullable)
nullable
- - Nullable object to generate an optional fromstatic <T> java.util.List<AnyMSeq<T>> listFromStreamable(java.lang.Iterable<Streamable<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(Streamable.of(1,2,3),Streamable.of(10,20,30));
//List[AnyM[Streamable[1,2,3],Streamable[10,20,30]]]
anyM
- Iterable containing Streamablesstatic <T> java.util.List<AnyMSeq<T>> listFromStream(java.lang.Iterable<java.util.stream.Stream<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStream(Arrays.asList(Stream.of(1,2,3),Stream.of(10,20,30));
//List[AnyM[Stream[1,2,3],Stream[10,20,30]]]
anyM
- Iterable containing Streamsstatic <T> java.util.List<AnyMValue<T>> listFromOptional(java.lang.Iterable<java.util.Optional<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(Optional.of(1),Optional.of(10));
//List[AnyM[Optional[1],Optional[10]]]
anyM
- Iterable containing Optionalstatic <T> java.util.List<AnyMValue<T>> listFromCompletableFuture(java.lang.Iterable<java.util.concurrent.CompletableFuture<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(CompletableFuture.completedFuture(1),CompletableFuture.supplyAsync(()->10));
//List[AnyM[CompletableFuture[1],CompleteableFuture[10]]]
anyM
- Iterable containing CompletableFuturestatic <T> java.util.List<AnyMSeq<T>> listFromIterable(java.lang.Iterable<java.lang.Iterable<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(Streamable.of(1,2,3),Streamable.of(10,20,30));
//List[AnyM[Streamable[1,2,3],Streamable[10,20,30]]]
anyM
- Iterable containing Streamablesstatic <T> java.util.List<AnyMSeq<T>> listFromCollection(java.lang.Iterable<java.util.Collection<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(Arrays.asList(1,2,3),Arrays.asList(10,20,30));
//List[AnyM[List[1,2,3],List[10,20,30]]]
anyM
- Iterable containing Collectionsstatic <ST,T> java.util.List<AnyMValue<T>> listFromXor(java.lang.Iterable<Xor<ST,T>> anyM)
static <ST,T> java.util.List<AnyMValue<T>> listFromIor(java.lang.Iterable<Ior<ST,T>> anyM)
static <T> java.util.List<AnyMValue<T>> listFromMaybe(java.lang.Iterable<Maybe<T>> anyM)
static <T> java.util.List<AnyMValue<T>> listFromFutureW(java.lang.Iterable<FutureW<T>> anyM)
static <T> java.util.List<AnyMSeq<T>> listFromIterator(java.lang.Iterable<java.util.Iterator<T>> anyM)
List<AnyM<Integer>> anyMs = AnyM.listFromStreamable(Arrays.asList(Arrays.asList(1,2,3).iterator(),Arrays.asList(10,20,30)).iterator();
//List[AnyM[Stream[1,2,3],Stream[10,20,30]]]
anyM
- Iterable containing Iteratorsstatic <T,R> AnyMValue<ListX<R>> traverse(java.util.Collection<? extends AnyM<T>> seq, java.util.function.Function<? super T,? extends R> fn)
List<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<String>> futureList = AnyMonads.traverse(AsAnyMList.anyMList(futures), (Integer i) -> "hello" +i);
seq
- Collection of Monadsfn
- Function to applystatic <T,R> AnyMValue<ListX<R>> traverse(java.util.stream.Stream<? extends AnyM<T>> seq, java.util.function.Function<? super T,? extends R> fn)
Stream<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<String>> futureList = AnyMonads.traverse(AsAnyMList.anyMList(futures), (Integer i) -> "hello" +i);
seq
- Stream of Monadsfn
- Function to applystatic <T1> AnyMValue<ListX<T1>> sequence(java.util.Collection<? extends AnyM<T1>> seq)
List<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<Integer>> futureList = AnyMonads.sequence(AsAnyMList.anyMList(futures));
//where AnyM wraps CompletableFuture<List<Integer>>
seq
- Collection of monads to convertfor helper methods to convert a List of Monads / Collections to List of AnyM
static <T1> AnyMValue<ListX<T1>> sequence(java.util.stream.Stream<? extends AnyM<T1>> seq)
Stream<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<Integer>> futureList = AnyMonads.sequence(AsAnyMList.anyMList(futures));
//where AnyM wraps CompletableFuture<List<Integer>>
seq
- Stream of monads to convertfor helper methods to convert a List of Monads / Collections to List of AnyM
static <U,R> java.util.function.Function<AnyM<U>,AnyM<R>> liftM(java.util.function.Function<? super U,? extends R> fn)
fn
- static <U1,U2,R> java.util.function.BiFunction<AnyM<U1>,AnyM<U2>,AnyM<R>> liftM2(java.util.function.BiFunction<? super U1,? super U2,? extends R> fn)
BiFunction<AnyM<Integer>,AnyM<Integer>,AnyM<Integer>> add = Monads.liftM2(this::add);
Optional<Integer> result = add.apply(getBase(),getIncrease());
private Integer add(Integer a, Integer b){
return a+b;
}
The add method has no null handling, but we can lift the method to Monadic form, and use Optionals to automatically handle null / empty value cases.fn
- BiFunction to liftstatic <U1,U2,U3,R> org.jooq.lambda.function.Function3<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<R>> liftM3(org.jooq.lambda.function.Function3<? super U1,? super U2,? super U3,? extends R> fn)
Function3 <AnyM<Double>,AnyM<Entity>,AnyM<String>,AnyM<Integer>> fn = liftM3(this::myMethod);
Now we can execute the Method with Streams, Optional, Futures, Try's etc to transparently inject iteration, null handling, async execution and / or error handlingfn
- Function to liftstatic <U1,U2,U3,R> TriFunction<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<R>> liftM3Cyclops(TriFunction<? super U1,? super U2,? super U3,? extends R> fn)
TriFunction<AnyM<Double>,AnyM<Entity>,AnyM<String>,AnyM<Integer>> fn = liftM3(this::myMethod);
Now we can execute the Method with Streams, Optional, Futures, Try's etc to transparently inject iteration, null handling, async execution and / or error handlingfn
- Function to liftstatic <U1,U2,U3,U4,R> org.jooq.lambda.function.Function4<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<U4>,AnyM<R>> liftM4(org.jooq.lambda.function.Function4<? super U1,? super U2,? super U3,? super U4,? extends R> fn)
fn
- Quad funciton to liftstatic <U1,U2,U3,U4,R> QuadFunction<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<U4>,AnyM<R>> liftM4Cyclops(QuadFunction<? super U1,? super U2,? super U3,? super U4,? extends R> fn)
fn
- Quad funciton to liftstatic <U1,U2,U3,U4,U5,R> org.jooq.lambda.function.Function5<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<U4>,AnyM<U5>,AnyM<R>> liftM5(org.jooq.lambda.function.Function5<? super U1,? super U2,? super U3,? super U4,? super U5,? extends R> fn)
fn
- Function to liftstatic <U1,U2,U3,U4,U5,R> QuintFunction<AnyM<U1>,AnyM<U2>,AnyM<U3>,AnyM<U4>,AnyM<U5>,AnyM<R>> liftM5Cyclops(QuintFunction<? super U1,? super U2,? super U3,? super U4,? super U5,? extends R> fn)
fn
- Function to liftstatic <U1,U2,R> java.util.function.Function<AnyM<U1>,java.util.function.Function<AnyM<U2>,AnyM<R>>> liftM2(java.util.function.Function<U1,java.util.function.Function<U2,R>> fn)
fn
- Function to liftstatic <U1,U2,U3,R> java.util.function.Function<AnyM<U1>,java.util.function.Function<AnyM<U2>,java.util.function.Function<AnyM<U3>,AnyM<R>>>> liftM3(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,? extends R>>> fn)
fn
- Function to liftstatic <U1,U2,U3,U4,R> java.util.function.Function<AnyM<U1>,java.util.function.Function<AnyM<U2>,java.util.function.Function<AnyM<U3>,java.util.function.Function<AnyM<U4>,AnyM<R>>>>> liftM4(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,java.util.function.Function<? super U4,? extends R>>>> fn)
fn
- Function to liftstatic <U1,U2,U3,U4,U5,R> java.util.function.Function<AnyM<U1>,java.util.function.Function<AnyM<U2>,java.util.function.Function<AnyM<U3>,java.util.function.Function<AnyM<U4>,java.util.function.Function<AnyM<U5>,AnyM<R>>>>>> liftM5(java.util.function.Function<? super U1,java.util.function.Function<? super U2,java.util.function.Function<? super U3,java.util.function.Function<? super U4,java.util.function.Function<? super U5,? extends R>>>>> fn)
(5 levels a->b->c->d->e->fn.apply(a,b,c,d,e) )
into Monadic formfn
- Function to lift