Class Choice<T>
java.lang.Object
com.google.errorprone.refaster.Choice<T>
A representation of a choice with zero or more options, which may be evaluated lazily or
strictly.
This resembles the list monad in Haskell.
- Author:
- lowasser@google.com (Louis Wasserman)
-
Method Summary
Modifier and TypeMethodDescriptionReturns a choice of the options from thisChoice
or fromother
.static <T> Choice
<T> condition
(boolean condition, T t) Returns aChoice
witht
as an option ifcondition
, and no options otherwise.Filters the choices to those that satisfy the providedPredicate
.Returns the first valid option from thisChoice
.<R> Choice
<R> Returns all the choices obtained by choosing from thisChoice
and then choosing from theChoice
yielded by this function on the result.static <T> Choice
<T> from
(Collection<T> choices) static <T> Choice
<T> fromOptional
(Optional<T> optional) Returns a choice of the optional value, if it is present, or the empty choice if it is absent.iterator()
<R> Choice
<R> Maps the choices with the specified function.<R> Choice
<R> mapIfPresent
(Function<? super T, Optional<R>> function) Returns all the choices obtained by choosing from thisChoice
and yielding a presentOptional
.static <T> Choice
<T> none()
The emptyChoice
.static <T> Choice
<T> of
(T t) Returns aChoice
with only one option,t
.toString()
-
Method Details
-
none
The emptyChoice
. -
of
Returns aChoice
with only one option,t
. -
condition
Returns aChoice
witht
as an option ifcondition
, and no options otherwise. -
fromOptional
-
from
-
iterator
-
toString
-
findFirst
-
flatMap
-
mapIfPresent
-
map
-
concat
-
filter
-