| Modifier and Type | Method and Description |
|---|---|
static <T,A,R> AdaptableCollector<T,A,R> |
adapt(Collector<T,A,R> collector)
Deprecated.
Use
Collectors.collectingAndThen(Collector, Function) instead. |
static <T> AdaptableCollector<T,OneTimeAssignment<T>,Optional<T>> |
allowAtMostOne()
This is a collector for accessing the expected singular only element of a
Stream, as
it will throw an exception if more than one element is processed. |
static <T> AdaptableCollector<T,OneTimeAssignment<T>,Optional<T>> |
allowAtMostOneOrElseThrow(BiFunction<? super T,? super T,? extends RuntimeException> exceptionOnExcessiveElements)
This is a collector for accessing the expected singular only element of a
Stream, as
it will throw the exception yielded from the given function 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> AdaptableCollector<T,OneTimeAssignment<T>,Optional<T>> allowAtMostOneOrElseThrow(BiFunction<? super T,? super T,? extends RuntimeException> exceptionOnExcessiveElements)
Stream, as
it will throw the exception yielded from the given function if more than one element is processed.the - function will be given the first element yielded from the stream as its first argument
and the unexpected excess one as the second, which may be used to construct an
exception to be thrown.allowAtMostOne()@Deprecated public static <T,A,R> AdaptableCollector<T,A,R> adapt(Collector<T,A,R> collector)
Collectors.collectingAndThen(Collector, Function) instead.Collector into an AdaptableCollector.collector - the collector to convertAdaptableCollectorAdaptableCollectorCopyright © 2016 Digipost. All rights reserved.