| Modifier and Type | Method and Description |
|---|---|
static <T,A,R> AdaptableCollector<T,A,R> |
adapt(Collector<T,A,R> collector)
Turn any
Collector into an AdaptableCollector. |
static <T> AdaptableCollector<T,OneTimeAssignment<T>,Optional<T>> |
allowAtMostOne()
This is a collector for accessing the expected only element of a
Stream, as
it will throw an exception if more than one element is processed. |
static <T1,T2> AdaptableCollector<ViewableAsTuple<T1,Optional<T2>>,?,Map<T1,List<T2>>> |
toMultimap()
A multimap maps from keys to lists, and this collector will arrange
tuples
by putting each distinct first tuple-element as keys of the resulting map, mapping
them to a List, and adding each second tuple-element to the list. |
static <T,K,V> AdaptableCollector<T,?,Map<K,List<V>>> |
toMultimap(Function<? super T,K> keyExtractor,
Function<? super T,Optional<V>> extractor) |
static <T,V> AdaptableCollector<T,?,Map<T,List<V>>> |
toMultimap(Function<? super T,Optional<V>> extractor) |
public static <T1,T2> AdaptableCollector<ViewableAsTuple<T1,Optional<T2>>,?,Map<T1,List<T2>>> toMultimap()
tuples
by putting each distinct first tuple-element as keys of the resulting map, mapping
them to a List, and adding each second tuple-element to the list.T1 - The type of the first tuple element, which will become the key type of the resulting Map.T2 - The type of the second tuple element, which will become the List<T2> value type of the
resulting Map.public static <T,V> AdaptableCollector<T,?,Map<T,List<V>>> toMultimap(Function<? super T,Optional<V>> extractor)
public static <T,K,V> AdaptableCollector<T,?,Map<K,List<V>>> toMultimap(Function<? super T,K> keyExtractor, Function<? super T,Optional<V>> extractor)
public static <T> AdaptableCollector<T,OneTimeAssignment<T>,Optional<T>> allowAtMostOne()
Stream, as
it will throw an exception if more than one element is processed. This should be used in
preference of the Stream.findFirst() or Stream.findAny() when it is imperative
that the stream indeed yields a maximum of one single element, and any more elements is
considered a programming error.public static <T,A,R> AdaptableCollector<T,A,R> adapt(Collector<T,A,R> collector)
Collector into an AdaptableCollector.collector - the collector to convertAdaptableCollectorAdaptableCollectorCopyright © 2016 Digipost. All rights reserved.