public class MoreCollectors
extends java.lang.Object
Constructor and Description |
---|
MoreCollectors() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> |
singleOrEmpty()
Collector which traverses a stream and returns either a single element
(if there was only one element) or empty (if there were 0 or more than 1
elements).
|
static <T> java.util.Optional<T> |
singleOrEmptyShortCircuiting(java.util.stream.Stream<T> stream)
Same behavior as MoreCollectors.singleOrEmpty(), except that it returns
early if it is possible to do so.
|
public static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> singleOrEmpty()
public static <T> java.util.Optional<T> singleOrEmptyShortCircuiting(java.util.stream.Stream<T> stream)