Package com.yahoo.collections
Class Optionals
java.lang.Object
com.yahoo.collections.Optionals
- Author:
- jonmv
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> boolean
emptyOrEqual
(Optional<T> optional, T value) Returns whether the optional is empty, or present and equal to the given value.static <T> boolean
equalIfBothPresent
(Optional<T> first, Optional<T> second) Returns whether either optional is empty, or both are present and equal.static <T> Optional<T>
firstNonEmpty
(Optional<T>... optionals) Returns the first non-empty optional, or empty if all are empty.static <T extends Comparable<T>>
Optional<T>Returns the non-empty optional with the highest value, or empty if all are empty.static <T extends Comparable<T>>
Optional<T>Returns the non-empty optional with the lowest value, or empty if all are empty.
-
Method Details
-
firstNonEmpty
Returns the first non-empty optional, or empty if all are empty. -
min
Returns the non-empty optional with the lowest value, or empty if all are empty. -
max
Returns the non-empty optional with the highest value, or empty if all are empty. -
equalIfBothPresent
Returns whether either optional is empty, or both are present and equal. -
emptyOrEqual
Returns whether the optional is empty, or present and equal to the given value.
-