public static class Maybe.Nothing<T> extends java.lang.Object implements Maybe<T>
Maybe.Just<T>, Maybe.Lazy<T>, Maybe.Nothing<T>
ApplicativeFunctor.Applicatives, ApplicativeFunctor.ApplyFunctions<T>
Value.ValueImpl<T>
Convertable.SupplierToConvertable<T>
Constructor and Description |
---|
Nothing() |
Modifier and Type | Method and Description |
---|---|
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> Maybe.Nothing<R> |
flatMapIterable(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.
|
<R> Maybe.Nothing<R> |
flatMapPublisher(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 |
get() |
boolean |
isPresent() |
<R> Maybe<R> |
map(java.util.function.Function<? super T,? extends R> mapper)
Transform this functor using the supplied transformation function
|
T |
orElse(T value)
Get the contained value or else the provided alternative
|
T |
orElseGet(java.util.function.Supplier<? extends T> value)
An equivalent operation to
Optional.orElseGet(Supplier)
Returns a value generated by the provided Supplier if this Convertable is empty or
contains a null value. |
Maybe<T> |
recover(java.util.function.Supplier<T> value) |
Maybe<T> |
recover(T value) |
java.util.Optional<T> |
toOptional() |
java.lang.String |
toString() |
<R> R |
visit(java.util.function.Function<? super T,? extends R> some,
java.util.function.Supplier<? extends R> none)
The provided function is executed with the value stored in this Visitable if one is present,
otherwise the provided Supplier is executed instead.
|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accumulateJust, accumulateJust, accumulateJust, cast, coflatMap, combine, combine, combineEager, filterNot, fromEval, fromEvalOf, fromIterable, fromOptional, fromPublisher, just, narrow, nest, none, notNull, of, ofNullable, ofType, patternMatch, peek, sequence, sequence, sequenceJust, toMaybe, trampoline, unit, zip, zip, zip, zip, zip, zip, zip
anyM
applyFunctions
collect, fold, fold, generate, iterate, iterator, mapReduce, mkString, newSubscriber, stream, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFeatureToggle, toFutureStream, toFutureStream, toIor, toLazyImmutable, toList, toListX, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, toTry, toXor, toXor, unapply
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldable, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, validate, xMatch
collect, fromSupplier, orElseThrow, toAtomicReference, toCompletableFuture, toCompletableFutureAsync, toCompletableFutureAsync, toFutureW, toFutureWAsync, toFutureWAsync, toOptionalAtomicReference, toStream
iterator
matches
public <R> Maybe<R> map(java.util.function.Function<? super T,? extends R> mapper)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface Maybe<T>
map
in interface ConvertableFunctor<T>
map
in interface Functor<T>
map
in interface MonadicValue<T>
map
in interface MonadicValue1<T>
mapper
- Transformation functionpublic <R> Maybe<R> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
MonadicValue1
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)
Filterable
of(1,2,3).filter(i->i>2);
//[3]
public T get()
get
in interface Convertable<T>
get
in interface java.util.function.Supplier<T>
public <R> R visit(java.util.function.Function<? super T,? extends R> some, java.util.function.Supplier<? extends R> none)
Visitable
visit
in interface Matchable.MatchableOptional<T>
visit
in interface Matchable.ValueAndOptionalMatcher<T>
visit
in interface Maybe<T>
visit
in interface Convertable<T>
visit
in interface Visitable<T>
some
- Function to execute if this Visitable has a valuenone
- Supplier to execute if this Visitable does not have a Valuepublic java.util.Optional<T> toOptional()
toOptional
in interface Matchable.MatchableOptional<T>
toOptional
in interface Matchable.ValueAndOptionalMatcher<T>
toOptional
in interface Convertable<T>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isPresent()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public T orElse(T value)
Convertable
orElse
in interface Convertable<T>
public T orElseGet(java.util.function.Supplier<? extends T> value)
Convertable
Optional.orElseGet(Supplier)
Returns a value generated by the provided Supplier if this Convertable is empty or
contains a null value.orElseGet
in interface Convertable<T>
value
- Supplier to generate value if this convertable is emptypublic <R> Maybe.Nothing<R> flatMapIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
MonadicValue1
Maybe.just(1).map(i->i+2).flatMapIterable(i->Arrays.asList(()->i*3,20);
//Maybe[9]
flatMapIterable
in interface Maybe<T>
flatMapIterable
in interface MonadicValue1<T>
mapper
- transformation functionpublic <R> Maybe.Nothing<R> flatMapPublisher(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
MonadicValue1
FutureW.ofResult(1).map(i->i+2).flatMapPublisher(i->Flux.just(()->i*3,20);
//FutureW[9]
flatMapPublisher
in interface Maybe<T>
flatMapPublisher
in interface MonadicValue1<T>
mapper
- transformation function