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. |
<R> Option<R> |
map(java.util.function.Function<T,R> function)
Always returns
this . |
Option<T> |
orElse(java.util.function.Supplier<Option<T>> s)
Always the value provided by the supplier.
|
java.util.stream.Stream<T> |
stream()
Always returns an empty stream.
|
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
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>> s)
public java.util.stream.Stream<T> stream()
public boolean equals(Object other)
public int hashCode()
0
as None is stateless and has no value.Copyright © 2015, Peter Nerg Apache License v2.0