public static final class Maybe.Just<T> extends java.lang.Object implements Maybe<T>, Present<T>
Maybe.CompletableMaybe<ORG,T2>, Maybe.Comprehensions, Maybe.Just<T>, Maybe.Lazy<T>, Maybe.Nothing<T>
Option.None<T>, Option.Some<T>
Constructor and Description |
---|
Just() |
Modifier and Type | Method and Description |
---|---|
<R> Maybe<R> |
concatMap(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
A flattening transformation operation that takes the first value from the returned Iterable.
|
boolean |
equals(java.lang.Object obj) |
Maybe<T> |
filter(java.util.function.Predicate<? super T> test)
Keep only elements for which the supplied predicates hold
e.g.
|
<R> Maybe<R> |
flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
A flattening transformation operation (@see
Optional.flatMap(Function) |
<R> R |
fold(java.util.function.Function<? super T,? extends R> fn1,
java.util.function.Function<? super Option.None<T>,? extends R> fn2) |
<R> R |
fold(java.util.function.Function<? super T,? extends R> some,
java.util.function.Supplier<? extends R> none) |
void |
forEach(java.util.function.Consumer<? super T> action) |
int |
hashCode() |
boolean |
isPresent() |
<R> Maybe<R> |
map(java.util.function.Function<? super T,? extends R> mapper)
Transform this functor using the supplied transformation function
|
<R> Maybe<R> |
mergeMap(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
A flattening transformation operation that takes the first value from the returned Publisher.
|
T |
orElse(T value) |
T |
orElseGet(java.util.function.Supplier<? extends T> value) |
Maybe<T> |
recover(java.util.function.Supplier<? extends T> value) |
Maybe<T> |
recover(T value) |
Maybe<T> |
recoverWith(java.util.function.Supplier<? extends Option<T>> fn) |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accumulateJust, accumulateJust, accumulateJust, arrow, async, attempt, attemptFlatMap, attemptMap, eager, filterNot, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, fromEval, fromEvalNullable, fromEvalOf, fromEvalOptional, fromFuture, fromIterable, fromLazy, fromLazyOption, fromOption, fromOptional, fromPublisher, fromStream, just, lazy, maybe, narrow, narrowK, narrowOptional, nothing, notNull, of, ofNullable, ofType, orElseUse, peek, sequence, sequence, sequence, sequenceJust, tailRec, toMaybe, toTrampoline, traverse, unit, widen, widen2, zip, zip, zip, zip3, zip3, zip4, zip4, zipWithPublisher
accumulateJust, accumulateJust, accumulateJust, emptyUnit, fromNullable, fromStream, narrow, none, sequence, sequence, sequence, sequenceJust, some, tailRec, traverse, widen, widen2
orElseUse
arity, mapAsync, mapRetry, mapRetry, mapTry, mapTry
asSupplier, collect, fold, generate, iterate, iterator, mkString, nonEmptyList, nonEmptyListGet, print, print, printErr, printOut, stream, subscribe, toEither, toLazyEither, toLeft, toOption, toOptional, toRight, toTry, toTry, toTry
public <R> Maybe<R> map(java.util.function.Function<? super T,? extends R> mapper)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
public <R> Maybe<R> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
MonadicValue
Optional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
public Maybe<T> filter(java.util.function.Predicate<? super T> test)
Filters
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface Filters<T>
filter
in interface MonadicValue<T>
filter
in interface Maybe<T>
filter
in interface Option<T>
test
- to filter elements by, retaining matchespublic <R> R fold(java.util.function.Function<? super T,? extends R> some, java.util.function.Supplier<? extends R> none)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isPresent()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public <R> Maybe<R> concatMap(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
MonadicValue
Maybe.just(1).map(i->i+2).concatMap(i->Arrays.asList(()->i*3,20);
//Maybe[9]
public <R> Maybe<R> mergeMap(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
MonadicValue
Future.ofResult(1).map(i->i+2).mergeMap(i->Flux.just(()->i*3,20);
//Future[9]
public Maybe<T> recoverWith(java.util.function.Supplier<? extends Option<T>> fn)
recoverWith
in interface Maybe<T>
recoverWith
in interface Option<T>
public void forEach(java.util.function.Consumer<? super T> action)
public <R> R fold(java.util.function.Function<? super T,? extends R> fn1, java.util.function.Function<? super Option.None<T>,? extends R> fn2)
fold
in interface Sealed2<T,Option.None<T>>