public final class OptionalUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> java.util.List<T> |
filterEmptyOptionals(java.util.Collection<java.util.Optional<T>> optionals)
Takes a
Collection of Optional s containing some elements of type T ,
this method filters out any empty Optional and returns a new list containing the values
of the non-empty optionals. |
static <T> java.util.List<T> |
filterEmptyOptionals(java.util.Optional<T>... optionals)
Takes zero or more
Optional s containing some elements of type T , this method
filters out any empty Optional and returns a new list containing the values of the
non-empty optionals. |
@Nonnull public static <T> java.util.List<T> filterEmptyOptionals(@Nonnull java.util.Collection<java.util.Optional<T>> optionals)
Collection
of Optional
s containing some elements of type T
,
this method filters out any empty Optional
and returns a new list containing the values
of the non-empty optionals.T
- The type of the elements in the Optionals in the supplied collection optionals
.optionals
- the collection of optionals that should be filtered out of empty optionals.optionals
collection.@Nonnull @SafeVarargs public static <T> java.util.List<T> filterEmptyOptionals(@Nonnull java.util.Optional<T>... optionals)
Optional
s containing some elements of type T
, this method
filters out any empty Optional
and returns a new list containing the values of the
non-empty optionals.T
- The type of the elements in the Optionals in the supplied collection optionals
.optionals
- zero or more optionals that should be filtered out of empty optionals.optionals
.