Please enable JavaScript.
Coggle requires JavaScript to display documents.
Optional<T> - Coggle Diagram
Optional<T>
Coloris notes
type of return
description
exceptions
methods
instance
static
Object
methods
static(3)
ofNullable(T t)
Optional<T>
if T is a non-null
Optional empty
if T is a null value
empty()
Empty Optional
of(T t)
Optional<T>
Throws:
NullPointerException
when T is null
T
instance
map(Function<? super T,? extends U> mapper)
returns a Empty Optional
if is not present
returns a
Optional<U>
of type U get from type T
if present
Throws:
NullPointerException
when mapping function is null
ifPresent(Consumer<? super T> consumer)
applys the Consumer under hte present vallue:
if present
does not apply the consumer
if is not present
void
Throws:
NullPointerException
when value is present and consumer is null
flatMap(Function<? super T,Optional<U>> mapper)
trhows
NullPointerException
when mapping function is null
returns a null resul
extract a optional<U> from a Optional<T>
if present
Optional<U>
if is not present
empty Optional
orElse(T other)
T value
if present
other value
if is not present
isPresent
boolean
T get()
when present
returns a T value from the Optional
throws
NoSuchElementException
when a value is not present
filter(Predicate<? super T> predicate)
Optional<T>
if value is present and matches the given predicate
Empty Optional
if value is not present
orElseGet(Supplier<? extends T> other)
T
if value is present
other.get()
if value does not is present
NullPointerException
when value is not present and other is null
orElseThrow(Supplier<? extends X> exceptionSupplier)
NullPointerException
wheno value is present and exceptionSupplier is null
T
when value is present
ExceptionSupplier
Object
equals
hashCode
toString
contains or not contain a null value
the schrodinger cat's
is present