Top Description Inners Fields Methods
io.vavr.control

public Interface Option<T>

extends Value<T>, Serializable
Known Direct Implementers
io.vavr.control.Option.Some, io.vavr.control.Option.None
Type Parameters
<T>
The type of the optional value.
Imports
io.vavr.PartialFunction, .Tuple, .Value, io.vavr.collection.Iterator, .Seq, .Vector, java.io.Serializable, java.util.NoSuchElementException, .Objects, .Optional, java.util.function.Consumer, .Function, .Predicate, .Supplier

Replacement for java.util.Optional.

Option is a monadic container type which represents an optional value. Instances of Option are either an instance of Some or the singleton None.

Most of the API is taken from java.util.Optional. A similar type can be found in Haskell and Scala.

Author
Daniel Dietrich

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Option.None<
The type of the optional value.
T
>

None is a singleton representation of the undefined Option.

public static class
Option.Some<
The type of the optional value.
T
>

Some represents a defined Option.

Field Summary

Modifier and TypeField and Description
public static final long

Method Summary

Modifier and TypeMethod and Description
public default <
The new value type
R
>
Option<R>

Returns:

A new Option instance containing value of type R
collect
(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined on value of this option.
partialFunction
)

Collects value that is in the domain of the given partialFunction by mapping the value to type R.

public boolean
equals(Object
An object
o
)

Redeclares io.vavr.Value.equals.

Clarifies that values have a proper equals() method implemented.

public default Option<T>

Returns:

Some(value) or None as specified
filter
(Predicate<? super T>
A predicate which is used to test an optional value
predicate
)

Returns Some(value) if this is a Some and the value satisfies the given predicate.

public default <
Component type of the resulting Option
U
>
Option<U>

Returns:

a new Option
flatMap
(Function<? super T, ? extends Option<? extends U>>
A mapper
mapper
)

Maps the value to a new Option if this is a Some, otherwise returns None.

public default <
type of the folded value
U
>
U

Returns:

A value of type U
fold
(Supplier<? extends U>
maps the left value if this is a None
ifNone
,
Function<? super T, ? extends U>
maps the value if this is a Some
f
)

Folds either the None or the Some side of the Option value.

public T

Returns:

the value
get
()

Redeclares io.vavr.Value.get.

Gets the value if this is a Some or throws if this is a None.

public default T

Returns:

This value, if this Option is defined or the other value, if this Option is empty.
getOrElse
(T
An alternative value
other
)

Overrides default io.vavr.Value.getOrElse.

Returns the value if this is a Some or the other value if this is a None.

public default T

Returns:

This value, if this Option is defined or the other value, if this Option is empty.
getOrElse
(Supplier<? extends T>
An alternative value supplier
supplier
)

Overrides default io.vavr.Value.getOrElse, io.vavr.Value.getOrElse.

Returns the value if this is a Some, otherwise the other value is returned, if this is a None.

public default <
A throwable
X extends Throwable
>
T

Returns:

This value, if this Option is defined, otherwise throws X
getOrElseThrow
(Supplier<X>
An exception supplier
exceptionSupplier
)

Overrides default io.vavr.Value.getOrElseThrow.

Returns the value if this is a Some, otherwise throws an exception.

public int
hashCode()

Redeclares io.vavr.Value.hashCode.

Clarifies that values have a proper hashCode() method implemented.

public default boolean

Returns:

false
isAsync
()

Implements io.vavr.Value.isAsync.

An Option's value is computed synchronously.

public default boolean

Returns:

true, if this Option has a defined value, false otherwise
isDefined
()

Returns true, if this is Some, otherwise false, if this is None.

public boolean

Returns:

true, if this Option is empty, false otherwise
isEmpty
()

Redeclares io.vavr.Value.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

public default boolean

Returns:

false
isLazy
()

Implements io.vavr.Value.isLazy.

An Option's value is computed eagerly.

public default boolean

Returns:

true
isSingleValued
()

Implements io.vavr.Value.isSingleValued.

An Option is single-valued.

public default Iterator<T>
iterator()

Implements io.vavr.Value.iterator.

Returns a rich io.vavr.collection.Iterator.

public default <
The new value type
U
>
Option<U>

Returns:

a new Some containing the mapped value if this Option is defined, otherwise None, if this is empty.
map
(Function<? super T, ? extends U>
A value mapper
mapper
)

Implements io.vavr.Value.map.

Maps the value and wraps it in a new Some if this is a Some, returns None.

public static <
Component type of the Option.
T
>
Option<T>

Returns:

the given option instance as narrowed type Option<T>.
narrow
(Option<? extends T>
A Option.
option
)

Narrows a widened Option<?

public static <
component type
T
>
Option<T>

Returns:

the single instance of None
none
()

Returns the single instance of None

public static <
type of the value
T
>
Option<T>

Returns:

Some(value) if value is not null, None otherwise
of
(T
A value
value
)

Creates a new Option of a given value.

public static <
type of the value
T
>
Option<T>

Returns:

Some(optional.get()) if value is Java Optional is present, None otherwise
ofOptional
(Optional<? extends T>
a given optional to wrap in Option
optional
)

Wraps a Java Optional to a new Option

public default Option<T>

Returns:

this Option
onEmpty
(Runnable
a given Runnable to be run
action
)

Runs a Java Runnable passed as parameter if this Option is empty.

public default Option<T>

Returns:

this Option if it is nonempty, otherwise return the alternative.
orElse
(Option<? extends T>
An alternative Option
other
)

Returns this Option if it is nonempty, otherwise return the alternative.

public default Option<T>

Returns:

this Option if it is nonempty, otherwise return the result of evaluating supplier.
orElse
(Supplier<? extends Option<? extends T>>
An alternative Option supplier
supplier
)

Returns this Option if it is nonempty, otherwise return the result of evaluating supplier.

public default Option<T>

Returns:

this Option
peek
(Consumer<? super T>
An action which can be applied to an optional value
action
)

Implements io.vavr.Value.peek.

Applies an action to this value, if this option is defined, otherwise does nothing.

public static <
type of the Options
T
>
Option<Seq<T>>

Returns:

An Option of a Seq of results
sequence
(Iterable<? extends Option<? extends T>>
An Iterable of Options
values
)

Reduces many Options into a single Option by transforming an Iterable<Option<?

public static <
type of the value
T
>
Option<T>

Returns:

Some(value)
some
(T
A value
value
)

Creates a new Some of a given value.

public String
toString()

Redeclares io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

public default <
Type of transformation result
U
>
U

Returns:

An instance of type U
transform
(Function<? super Option<T>, ? extends U>
A transformation
f
)

Transforms this Option.

public static <
The type of the given values.
T
,
The mapped value type.
U
>
Option<Seq<U>>

Returns:

A Option of a Seq of results.
traverse
(Iterable<? extends T>
An Iterable of values.
values
,
Function<? super T, ? extends Option<? extends U>>
A mapper of values to Options
mapper
)

Maps the values of an iterable to a sequence of mapped values into a single Option by transforming an Iterable<?

public static <
type of the optional value
T
>
Option<T>

Returns:

return Some of supplier's value if condition is true, or None in other case
when
(boolean
A boolean value
condition
,
Supplier<? extends T>
An optional value supplier, may supply null
supplier
)

Creates Some of suppliers value if condition is true, or None in other case

public static <
type of the optional value
T
>
Option<T>

Returns:

return Some of value if condition is true, or None in other case
when
(boolean
A boolean value
condition
,
T
An optional value, may be null
value
)

Creates Some of value if condition is true, or None in other case

Inherited from io.vavr.Value:
collectcollectcontainscorrespondseqexistsforAllforEachgetOrElseTrygetOrNullnarrowoutoutspliteratorstderrstdoutstringPrefixtoArraytoCharSeqtoCompletableFuturetoEithertoEithertoInvalidtoInvalidtoJavaArraytoJavaArraytoJavaArraytoJavaCollectiontoJavaListtoJavaListtoJavaMaptoJavaMaptoJavaMaptoJavaOptionaltoJavaParallelStreamtoJavaSettoJavaSettoJavaStreamtoLefttoLefttoLinkedMaptoLinkedMaptoLinkedSettoListtoMaptoMaptoOptiontoPriorityQueuetoPriorityQueuetoQueuetoRighttoRighttoSettoSortedMaptoSortedMaptoSortedMaptoSortedMaptoSortedSettoSortedSettoStreamtoTreetoTreetoTrytoTrytoValidtoValidtoValidationtoValidationtoVector

Field Detail

serialVersionUIDback to summary
public static final long serialVersionUID

Method Detail

collectback to summary
public default <R> Option<R> collect(PartialFunction<? super T, ? extends R> partialFunction)

Collects value that is in the domain of the given partialFunction by mapping the value to type R.

partialFunction.isDefinedAt(value)
If the element makes it through that filter, the mapped instance is wrapped in Option
R newValue = partialFunction.apply(value)
Parameters
<R>
The new value type
partialFunction:PartialFunction<? super T, ? extends R>

A function that is not necessarily defined on value of this option.

Returns:Option<R>

A new Option instance containing value of type R

Exceptions
NullPointerException:
if partialFunction is null
equalsback to summary
public boolean equals(Object o)

Redeclares io.vavr.Value.equals.

Doc from io.vavr.Value.equals.

Clarifies that values have a proper equals() method implemented.

See Object.equals(Object).

Parameters
o:Object

An object

Returns:boolean

true, if this equals o, false otherwise

Annotations
@Override
filterback to summary
public default Option<T> filter(Predicate<? super T> predicate)

Returns Some(value) if this is a Some and the value satisfies the given predicate. Otherwise None is returned.

Parameters
predicate:Predicate<? super T>

A predicate which is used to test an optional value

Returns:Option<T>

Some(value) or None as specified

flatMapback to summary
public default <U> Option<U> flatMap(Function<? super T, ? extends Option<? extends U>> mapper)

Maps the value to a new Option if this is a Some, otherwise returns None.

Parameters
<U>
Component type of the resulting Option
mapper:Function<? super T, ? extends Option<? extends U>>

A mapper

Returns:Option<U>

a new Option

Annotations
@SuppressWarnings:unchecked
foldback to summary
public default <U> U fold(Supplier<? extends U> ifNone, Function<? super T, ? extends U> f)

Folds either the None or the Some side of the Option value.

Parameters
<U>
type of the folded value
ifNone:Supplier<? extends U>

maps the left value if this is a None

f:Function<? super T, ? extends U>

maps the value if this is a Some

Returns:U

A value of type U

getback to summary
public T get()

Redeclares io.vavr.Value.get.

Gets the value if this is a Some or throws if this is a None.

Returns:T

the value

Annotations
@Override
Exceptions
NoSuchElementException:
if this is a None.
getOrElseback to summary
public default T getOrElse(T other)

Overrides default io.vavr.Value.getOrElse.

Returns the value if this is a Some or the other value if this is a None.

Please note, that the other value is eagerly evaluated.

Parameters
other:T

An alternative value

Returns:T

This value, if this Option is defined or the other value, if this Option is empty.

Annotations
@Override
getOrElseback to summary
public default T getOrElse(Supplier<? extends T> supplier)

Overrides default io.vavr.Value.getOrElse, io.vavr.Value.getOrElse.

Returns the value if this is a Some, otherwise the other value is returned, if this is a None.

Please note, that the other value is lazily evaluated.

Parameters
supplier:Supplier<? extends T>

An alternative value supplier

Returns:T

This value, if this Option is defined or the other value, if this Option is empty.

Annotations
@Override
getOrElseThrowback to summary
public default <X extends Throwable> T getOrElseThrow(Supplier<X> exceptionSupplier) throws Supplier-:X

Overrides default io.vavr.Value.getOrElseThrow.

Returns the value if this is a Some, otherwise throws an exception.

Parameters
<X>
A throwable
exceptionSupplier:Supplier<X>

An exception supplier

Returns:T

This value, if this Option is defined, otherwise throws X

Annotations
@Override
Exceptions
Supplier-:X:
a throwable
hashCodeback to summary
public int hashCode()

Redeclares io.vavr.Value.hashCode.

Doc from io.vavr.Value.hashCode.

Clarifies that values have a proper hashCode() method implemented.

See Object.hashCode().

Returns:int

The hashcode of this object

Annotations
@Override
isAsyncback to summary
public default boolean isAsync()

Implements io.vavr.Value.isAsync.

An Option's value is computed synchronously.

Returns:boolean

false

Annotations
@Override
isDefinedback to summary
public default boolean isDefined()

Returns true, if this is Some, otherwise false, if this is None.

Please note that it is possible to create new Some(null), which is defined.

Returns:boolean

true, if this Option has a defined value, false otherwise

isEmptyback to summary
public boolean isEmpty()

Redeclares io.vavr.Value.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

Returns:boolean

true, if this Option is empty, false otherwise

Annotations
@Override
isLazyback to summary
public default boolean isLazy()

Implements io.vavr.Value.isLazy.

An Option's value is computed eagerly.

Returns:boolean

false

Annotations
@Override
isSingleValuedback to summary
public default boolean isSingleValued()

Implements io.vavr.Value.isSingleValued.

An Option is single-valued.

Returns:boolean

true

Annotations
@Override
iteratorback to summary
public default Iterator<T> iterator()

Implements io.vavr.Value.iterator.

Doc from io.vavr.Value.iterator.

Returns a rich io.vavr.collection.Iterator.

Returns:Iterator<T>

A new Iterator

Annotations
@Override
mapback to summary
public default <U> Option<U> map(Function<? super T, ? extends U> mapper)

Implements io.vavr.Value.map.

Maps the value and wraps it in a new Some if this is a Some, returns None.

Parameters
<U>
The new value type
mapper:Function<? super T, ? extends U>

A value mapper

Returns:Option<U>

a new Some containing the mapped value if this Option is defined, otherwise None, if this is empty.

Annotations
@Override
narrowback to summary
public static <T> Option<T> narrow(Option<? extends T> option)

Narrows a widened Option<? extends T> to Option<T> by performing a type-safe cast. This is eligible because immutable/read-only collections are covariant.

Parameters
<T>
Component type of the Option.
option:Option<? extends T>

A Option.

Returns:Option<T>

the given option instance as narrowed type Option<T>.

Annotations
@SuppressWarnings:unchecked
noneback to summary
public static <T> Option<T> none()

Returns the single instance of None

Parameters
<T>
component type
Returns:Option<T>

the single instance of None

ofback to summary
public static <T> Option<T> of(T value)

Creates a new Option of a given value.

Parameters
<T>
type of the value
value:T

A value

Returns:Option<T>

Some(value) if value is not null, None otherwise

ofOptionalback to summary
public static <T> Option<T> ofOptional(Optional<? extends T> optional)

Wraps a Java Optional to a new Option

Parameters
<T>
type of the value
optional:Optional<? extends T>

a given optional to wrap in Option

Returns:Option<T>

Some(optional.get()) if value is Java Optional is present, None otherwise

Annotations
@SuppressWarnings:OptionalUsedAsFieldOrParameterType
onEmptyback to summary
public default Option<T> onEmpty(Runnable action)

Runs a Java Runnable passed as parameter if this Option is empty.

Parameters
action:Runnable

a given Runnable to be run

Returns:Option<T>

this Option

orElseback to summary
public default Option<T> orElse(Option<? extends T> other)

Returns this Option if it is nonempty, otherwise return the alternative.

Parameters
other:Option<? extends T>

An alternative Option

Returns:Option<T>

this Option if it is nonempty, otherwise return the alternative.

Annotations
@SuppressWarnings:unchecked
orElseback to summary
public default Option<T> orElse(Supplier<? extends Option<? extends T>> supplier)

Returns this Option if it is nonempty, otherwise return the result of evaluating supplier.

Parameters
supplier:Supplier<? extends Option<? extends T>>

An alternative Option supplier

Returns:Option<T>

this Option if it is nonempty, otherwise return the result of evaluating supplier.

Annotations
@SuppressWarnings:unchecked
peekback to summary
public default Option<T> peek(Consumer<? super T> action)

Implements io.vavr.Value.peek.

Applies an action to this value, if this option is defined, otherwise does nothing.

Parameters
action:Consumer<? super T>

An action which can be applied to an optional value

Returns:Option<T>

this Option

Annotations
@Override
sequenceback to summary
public static <T> Option<Seq<T>> sequence(Iterable<? extends Option<? extends T>> values)

Reduces many Options into a single Option by transforming an Iterable<Option<? extends T>> into a Option<Seq<T>>. If any of the Options are Option.None, then this returns Option.None.

Parameters
<T>
type of the Options
values:Iterable<? extends Option<? extends T>>

An Iterable of Options

Returns:Option<Seq<T>>

An Option of a Seq of results

Exceptions
NullPointerException:
if values is null
someback to summary
public static <T> Option<T> some(T value)

Creates a new Some of a given value.

The only difference to Option#of(Object) is, when called with argument null.


Option.of(null);   // = None
Option.some(null); // = Some(null)

Parameters
<T>
type of the value
value:T

A value

Returns:Option<T>

Some(value)

toStringback to summary
public String toString()

Redeclares io.vavr.Value.toString.

Doc from io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

See Object.toString().

Returns:String

A String representation of this object

Annotations
@Override
transformback to summary
public default <U> U transform(Function<? super Option<T>, ? extends U> f)

Transforms this Option.

Parameters
<U>
Type of transformation result
f:Function<? super Option<T>, ? extends U>

A transformation

Returns:U

An instance of type U

Exceptions
NullPointerException:
if f is null
traverseback to summary
public static <T, U> Option<Seq<U>> traverse(Iterable<? extends T> values, Function<? super T, ? extends Option<? extends U>> mapper)

Maps the values of an iterable to a sequence of mapped values into a single Option by transforming an Iterable<? extends T> into a Option<Seq<U>>.

Parameters
<T>
The type of the given values.
<U>
The mapped value type.
values:Iterable<? extends T>

An Iterable of values.

mapper:Function<? super T, ? extends Option<? extends U>>

A mapper of values to Options

Returns:Option<Seq<U>>

A Option of a Seq of results.

Exceptions
NullPointerException:
if values or f is null.
whenback to summary
public static <T> Option<T> when(boolean condition, Supplier<? extends T> supplier)

Creates Some of suppliers value if condition is true, or None in other case

Parameters
<T>
type of the optional value
condition:boolean

A boolean value

supplier:Supplier<? extends T>

An optional value supplier, may supply null

Returns:Option<T>

return Some of supplier's value if condition is true, or None in other case

Exceptions
NullPointerException:
if the given supplier is null
whenback to summary
public static <T> Option<T> when(boolean condition, T value)

Creates Some of value if condition is true, or None in other case

Parameters
<T>
type of the optional value
condition:boolean

A boolean value

value:T

An optional value, may be null

Returns:Option<T>

return Some of value if condition is true, or None in other case

io.vavr.control back to summary

public final Class Option.None<T>

extends Object
implements Option<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, io.vavr.control.Option, io.vavr.Value, java.lang.Iterable
Type Parameters
<T>
The type of the optional value.

None is a singleton representation of the undefined Option.
Author
Daniel Dietrich

Field Summary

Modifier and TypeField and Description
private static final Option.None<?>
INSTANCE

The singleton instance of None.

private static final long

Constructor Summary

AccessConstructor and Description
private
None()

Hidden constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
An object
o
)

Overrides java.lang.Object.equals.

Implements io.vavr.control.Option.equals.

Clarifies that values have a proper equals() method implemented.

public T
get()

Implements io.vavr.control.Option.get.

Gets the value if this is a Some or throws if this is a None.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.control.Option.hashCode.

Clarifies that values have a proper hashCode() method implemented.

public boolean
isEmpty()

Implements io.vavr.control.Option.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

private Object

Returns:

The singleton instance of None.
readResolve
()

Instance control for object serialization.

public String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.control.Option.toString.

Clarifies that values have a proper toString() method implemented.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

INSTANCEback to summary
private static final Option.None<?> INSTANCE

The singleton instance of None.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.vavr.control.Option.serialVersionUID.

Constructor Detail

Noneback to summary
private None()

Hidden constructor.

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements io.vavr.control.Option.equals.

Doc from io.vavr.Value.equals.

Clarifies that values have a proper equals() method implemented.

See Object.equals(Object).

Parameters
o:Object

An object

Returns:boolean

true, if this equals o, false otherwise

Annotations
@Override
getback to summary
public T get()

Implements io.vavr.control.Option.get.

Doc from io.vavr.control.Option.get.

Gets the value if this is a Some or throws if this is a None.

Returns:T

the value

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.control.Option.hashCode.

Doc from io.vavr.Value.hashCode.

Clarifies that values have a proper hashCode() method implemented.

See Object.hashCode().

Returns:int

The hashcode of this object

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements io.vavr.control.Option.isEmpty.

Doc from io.vavr.control.Option.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

Returns:boolean

true, if this Option is empty, false otherwise

Annotations
@Override
readResolveback to summary
private Object readResolve()

Instance control for object serialization.

Returns:Object

The singleton instance of None.

See Also
Serializable
stringPrefixback to summary
public String stringPrefix()

Implements io.vavr.Value.stringPrefix.

Doc from io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

Returns:String

This type name.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements io.vavr.control.Option.toString.

Doc from io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

See Object.toString().

Returns:String

A String representation of this object

Annotations
@Override
io.vavr.control back to summary

public final Class Option.Some<T>

extends Object
implements Option<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, io.vavr.control.Option, io.vavr.Value, java.lang.Iterable
Type Parameters
<T>
The type of the optional value.

Some represents a defined Option. It contains a value which may be null. However, to create an Option containing null, new Some(null) has to be called. In all other cases Option#of(Object) is sufficient.
Author
Daniel Dietrich

Field Summary

Modifier and TypeField and Description
private static final long
private final T

Constructor Summary

AccessConstructor and Description
private
Some(T
A value, may be null
value
)

Creates a new Some containing the given value.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
An object
obj
)

Overrides java.lang.Object.equals.

Implements io.vavr.control.Option.equals.

Clarifies that values have a proper equals() method implemented.

public T
get()

Implements io.vavr.control.Option.get.

Gets the value if this is a Some or throws if this is a None.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.control.Option.hashCode.

Clarifies that values have a proper hashCode() method implemented.

public boolean
isEmpty()

Implements io.vavr.control.Option.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

public String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.control.Option.toString.

Clarifies that values have a proper toString() method implemented.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.vavr.control.Option.serialVersionUID.

valueback to summary
private final T value
Annotations
@SuppressWarnings:serial

Constructor Detail

Someback to summary
private Some(T value)

Creates a new Some containing the given value.

Parameters
value:T

A value, may be null

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements io.vavr.control.Option.equals.

Doc from io.vavr.Value.equals.

Clarifies that values have a proper equals() method implemented.

See Object.equals(Object).

Parameters
obj:Object

An object

Returns:boolean

true, if this equals o, false otherwise

Annotations
@Override
getback to summary
public T get()

Implements io.vavr.control.Option.get.

Doc from io.vavr.control.Option.get.

Gets the value if this is a Some or throws if this is a None.

Returns:T

the value

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.control.Option.hashCode.

Doc from io.vavr.Value.hashCode.

Clarifies that values have a proper hashCode() method implemented.

See Object.hashCode().

Returns:int

The hashcode of this object

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements io.vavr.control.Option.isEmpty.

Doc from io.vavr.control.Option.isEmpty.

Returns true, if this is None, otherwise false, if this is Some.

Returns:boolean

true, if this Option is empty, false otherwise

Annotations
@Override
stringPrefixback to summary
public String stringPrefix()

Implements io.vavr.Value.stringPrefix.

Doc from io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

Returns:String

This type name.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements io.vavr.control.Option.toString.

Doc from io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

See Object.toString().

Returns:String

A String representation of this object

Annotations
@Override