T
- public abstract class BaseAnyMImpl<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class |
initialType |
protected Monad<T> |
monad |
Constructor and Description |
---|
BaseAnyMImpl() |
Modifier and Type | Method and Description |
---|---|
protected AnyM<java.util.List<T>> |
aggregate(AnyM<T> next)
Aggregate the contents of this Monad and the supplied Monad
|
ReactiveSeq<T> |
asSequence()
Wrap this Monad's contents as a Sequence without disaggreating it.
|
protected <R> Monad<R> |
bindInternal(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
|
abstract <T> AnyM<T> |
empty() |
protected Monad<T> |
filterInternal(java.util.function.Predicate<? super T> fn) |
protected <R> Monad<R> |
flatMapInternal(java.util.function.Function<? super T,? extends AnyM<? extends R>> fn) |
protected <T1> Monad<T1> |
flattenInternal()
join / flatten one level of a nested hierarchy
|
void |
forEach(java.util.function.Consumer<? super T> action) |
T |
get() |
protected <R> Monad<R> |
mapInternal(java.util.function.Function<? super T,? extends R> fn) |
Monad |
monad() |
protected Monad<T> |
peekInternal(java.util.function.Consumer<? super T> c) |
AnyMSeq<T> |
reduceMSeq(Monoid<AnyMSeq<T>> reducer) |
AnyMValue<T> |
reduceMValue(Monoid<AnyMValue<T>> reducer) |
ReactiveSeq<T> |
stream() |
java.util.List<T> |
toList() |
<T> ReactiveSeq<T> |
toSequence()
Optional<List<Integer>> into Stream<Integer> |
<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.util.Set<T> |
toSet() |
java.lang.String |
toString() |
abstract <T> AnyM<T> |
unit(T value) |
<R> R |
unwrap() |
public <R> R unwrap()
public Monad monad()
protected <R> Monad<R> mapInternal(java.util.function.Function<? super T,? extends R> fn)
protected <R> Monad<R> bindInternal(java.util.function.Function<? super T,?> fn)
fn
- flatMap functionprotected <R> Monad<R> flatMapInternal(java.util.function.Function<? super T,? extends AnyM<? extends R>> fn)
protected <T1> Monad<T1> flattenInternal()
protected AnyM<java.util.List<T>> aggregate(AnyM<T> next)
List<Integer> result = anyM(Stream.of(1,2,3,4))
.aggregate(anyM(Optional.of(5)))
.asSequence()
.toList();
assertThat(result,equalTo(Arrays.asList(1,2,3,4,5)));
next
- Monad to aggregate content withpublic void forEach(java.util.function.Consumer<? super T> action)
public <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(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));
public <T> ReactiveSeq<T> toSequence()
Optional<List<Integer>> into Stream<Integer>
Less type safe equivalent, but may be more accessible than toSequence(fn) i.e.
toSequence(Function<T,Stream<NT>> fn)
List<Integer> list = anyM(Optional.of(Arrays.asList(1,2,3,4,5,6)))
.<Integer>toSequence()
.collect(Collectors.toList());
public ReactiveSeq<T> asSequence()
Optional<List<Integer>> into Stream<List<Integer>>
If the underlying monad is a Stream it is returned
Otherwise we flatMap the underlying monad to a Stream typepublic abstract <T> AnyM<T> unit(T value)
public abstract <T> AnyM<T> empty()
public ReactiveSeq<T> stream()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<T> toList()
public java.util.Set<T> toSet()
public T get()