Package com.brightcove.player.data
Class Optional<T>
java.lang.Object
com.brightcove.player.data.Optional<T>
- Type Parameters:
T
- the expected type of the nullable value.
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.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Optional
Constructs a new optional value- Parameters:
value
- the optional value
-
-
Method Details
-
from
-
isPresent
public boolean isPresent()Checks if a non-null value is present.- Returns:
- true if there is a value present, otherwise false.
-
get
Gets the optional value if present.- Returns:
- reference to the optional value.
- Throws:
NoSuchElementException
- if the value is null.
-
hashCode
public int hashCode() -
equals
-
empty
Returns an empty Optional instance. No value is present for this Optional.- Type Parameters:
T
- Type of the optional value- Returns:
- an empty Optional
-