Optional

open class Optional<T>

Optional wrapper can be to pass nullable value safely through RxJava2 stream. Though Android supports this construct since API level 24, using it is not viable because the SDK has to support lower API levels.

Author

rsubramaniam

Parameters

<T>

the expected type of the nullable value.

Constructors

Link copied to clipboard
constructor(value: T)
Constructs a new optional value

Functions

Link copied to clipboard
open fun <T> empty(): Optional<T>
Returns an empty Optional instance.
Link copied to clipboard
open fun equals(rhs: Any): Boolean
Link copied to clipboard
open fun <T> from(value: T): Optional<T>
Link copied to clipboard
open fun get(): T
Gets the optional value if present.
Link copied to clipboard
open fun hashCode(): Int
Link copied to clipboard
open fun isPresent(): Boolean
Checks if a non-null value is present.