T
- The type of the value represented by this instancepublic final class None<T> extends Object implements Option<T>, Serializable
Option
. None
is a replacement for null
values representing a non-existing value. None
as a collection of size 0. Option
.
Since None
anyways cannot represent a value it is preferable to use it as a singleton saving unnecessary instance creation. Option
.DEFAULT_NONE
Constructor and Description |
---|
None() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
|
boolean |
exists(java.util.function.Predicate<T> predicate)
Always returns
false . |
<R> Option<R> |
flatMap(java.util.function.Function<T,Option<R>> function)
Always returns
this . |
T |
get()
Always throws
NoSuchElementException since None cannot per definition hold any value. |
T |
getOrElse(java.util.function.Supplier<T> supplier)
Always the value provided by the supplier.
|
int |
hashCode()
Always returns
0 as None is stateless and has no value. |
Iterator<T> |
iterator()
Always returns an empty iterator.
|
<R> Option<R> |
map(java.util.function.Function<T,R> function)
Always returns
this . |
Option<T> |
orElse(java.util.function.Supplier<Option<T>> supplier)
Always the value provided by the supplier.
|
java.util.stream.Stream<T> |
stream()
Always returns an empty stream.
|
<R> Either<T,R> |
toLeft(java.util.function.Supplier<R> right)
Returns a
Right containing the value from the provided supplier. |
<L> Either<L,T> |
toRight(java.util.function.Supplier<L> left)
Returns a
Left containing the value from the provided supplier. |
String |
toString()
Returns a String representation of the instance.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
apply, asOptional, contains, count, empty, filter, filterNot, forall, isDefined, isEmpty, iterator, None, ofOptional, orNull, stream
forEach, spliterator
public T get()
NoSuchElementException
since None cannot per definition hold any value.public T getOrElse(java.util.function.Supplier<T> supplier)
public boolean exists(java.util.function.Predicate<T> predicate)
public <R> Option<R> map(java.util.function.Function<T,R> function)
public <R> Option<R> flatMap(java.util.function.Function<T,Option<R>> function)
public Option<T> orElse(java.util.function.Supplier<Option<T>> supplier)
public <R> Either<T,R> toLeft(java.util.function.Supplier<R> right)
Right
containing the value from the provided supplier.public <L> Either<L,T> toRight(java.util.function.Supplier<L> left)
Left
containing the value from the provided supplier.public boolean equals(Object other)
public int hashCode()
0
as None is stateless and has no value.public String toString()
public final Iterator<T> iterator()
public final java.util.stream.Stream<T> stream()
Copyright © 2016, Peter Nerg Apache License v2.0