| Modifier and Type | Method and Description |
|---|---|
static <T> Collector<T,?,Double> |
averaging(Function<? super T,Double> mapper)
Deprecated.
As of release 1.1.3, replaced by
averagingDouble(com.annimon.stream.function.ToDoubleFunction) |
static <T> Collector<T,?,Double> |
averagingDouble(ToDoubleFunction<? super T> mapper)
Returns a
Collector that calculates average of double-valued input elements. |
static <T> Collector<T,?,Double> |
averagingInt(ToIntFunction<? super T> mapper)
Returns a
Collector that calculates average of integer-valued input elements. |
static <T> Collector<T,?,Double> |
averagingLong(ToLongFunction<? super T> mapper)
Returns a
Collector that calculates average of long-valued input elements. |
static <T,A,IR,OR> |
collectingAndThen(Collector<T,A,IR> c,
Function<IR,OR> finisher)
Returns a
Collector that performs additional transformation. |
static <T> Collector<T,?,Long> |
counting()
Returns a
Collector that counts the number of input elements. |
static <T,A,R> Collector<T,?,R> |
filtering(Predicate<? super T> predicate,
Collector<? super T,A,R> downstream)
Returns a
Collector that filters input elements. |
static <T,U,A,R> Collector<T,?,R> |
flatMapping(Function<? super T,? extends Stream<? extends U>> mapper,
Collector<? super U,A,R> downstream)
Returns a
Collector that performs flat-mapping before accumulation. |
static <T,K> Collector<T,?,Map<K,List<T>>> |
groupingBy(Function<? super T,? extends K> classifier)
Returns a
Collector that performs grouping operation by given classifier. |
static <T,K,A,D> Collector<T,?,Map<K,D>> |
groupingBy(Function<? super T,? extends K> classifier,
Collector<? super T,A,D> downstream)
Returns a
Collector that performs grouping operation by given classifier. |
static <T,K,D,A,M extends Map<K,D>> |
groupingBy(Function<? super T,? extends K> classifier,
Supplier<M> mapFactory,
Collector<? super T,A,D> downstream)
Returns a
Collector that performs grouping operation by given classifier. |
static Collector<CharSequence,?,String> |
joining()
Returns a
Collector that concatenates input elements into new string. |
static Collector<CharSequence,?,String> |
joining(CharSequence delimiter)
Returns a
Collector that concatenates input elements into new string. |
static Collector<CharSequence,?,String> |
joining(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix)
Returns a
Collector that concatenates input elements into new string. |
static Collector<CharSequence,?,String> |
joining(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix,
String emptyValue)
Returns a
Collector that concatenates input elements into new string. |
static <T,U,A,R> Collector<T,?,R> |
mapping(Function<? super T,? extends U> mapper,
Collector<? super U,A,R> downstream)
Returns a
Collector that performs mapping before accumulation. |
static <T> Collector<T,?,Map<Boolean,List<T>>> |
partitioningBy(Predicate<? super T> predicate)
Returns a
Collector that performs partitioning operation according to a predicate. |
static <T,D,A> Collector<T,?,Map<Boolean,D>> |
partitioningBy(Predicate<? super T> predicate,
Collector<? super T,A,D> downstream)
Returns a
Collector that performs partitioning operation according to a predicate. |
static <T,R> Collector<T,?,R> |
reducing(R identity,
Function<? super T,? extends R> mapper,
BinaryOperator<R> op)
Returns a
Collector that reduces input elements. |
static <T> Collector<T,?,T> |
reducing(T identity,
BinaryOperator<T> op)
Returns a
Collector that reduces input elements. |
static <T> Collector<T,?,Double> |
summingDouble(ToDoubleFunction<? super T> mapper)
Returns a
Collector that summing double-valued input elements. |
static <T> Collector<T,?,Integer> |
summingInt(ToIntFunction<? super T> mapper)
Returns a
Collector that summing integer-valued input elements. |
static <T> Collector<T,?,Long> |
summingLong(ToLongFunction<? super T> mapper)
Returns a
Collector that summing long-valued input elements. |
static <T,R extends Collection<T>> |
toCollection(Supplier<R> collectionSupplier)
Returns a
Collector that fills new Collection, provided by collectionSupplier,
with input elements. |
static <T> Collector<T,?,List<T>> |
toList()
Returns a
Collector that fills new List with input elements. |
static <T,K> Collector<T,?,Map<K,T>> |
toMap(Function<? super T,? extends K> keyMapper)
Returns a
Collector that fills new Map with input elements. |
static <T,K,V> Collector<T,?,Map<K,V>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper)
Returns a
Collector that fills new Map with input elements. |
static <T,K,V> Collector<T,?,Map<K,V>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper,
BinaryOperator<V> mergeFunction)
Returns a
Collector that fills new Map with input elements. |
static <T,K,V,M extends Map<K,V>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper,
BinaryOperator<V> mergeFunction,
Supplier<M> mapFactory)
Returns a
Collector that fills new Map with input elements. |
static <T,K,V,M extends Map<K,V>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper,
Supplier<M> mapFactory)
Returns a
Collector that fills new Map with input elements. |
static <T> Collector<T,?,Set<T>> |
toSet()
Returns a
Collector that fills new Set with input elements. |
static <T> Collector<T,?,List<T>> |
toUnmodifiableList()
Returns a
Collector that fills new unmodifiable List with input elements. |
static <T,K,V> Collector<T,?,Map<K,V>> |
toUnmodifiableMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper)
Returns a
Collector that fills new unmodifiable Map with input elements. |
static <T,K,V> Collector<T,?,Map<K,V>> |
toUnmodifiableMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper,
BinaryOperator<V> mergeFunction)
Returns a
Collector that fills new unmodifiable Map with input elements. |
static <T> Collector<T,?,Set<T>> |
toUnmodifiableSet()
Returns a
Collector that fills new unmodifiable Set with input elements. |
public static <T,R extends Collection<T>> Collector<T,?,R> toCollection(Supplier<R> collectionSupplier)
Collector that fills new Collection, provided by collectionSupplier,
with input elements.T - the type of the input elementsR - the type of the resulting collectioncollectionSupplier - a supplier function that provides new collectionCollectorpublic static <T> Collector<T,?,List<T>> toList()
Collector that fills new List with input elements.T - the type of the input elementsCollectorpublic static <T> Collector<T,?,List<T>> toUnmodifiableList()
Collector that fills new unmodifiable List with input elements.
The returned Collector disallows nulls
and throws NullPointerException if it is presented with a null value.T - the type of the input elementsCollectorpublic static <T> Collector<T,?,Set<T>> toSet()
Collector that fills new Set with input elements.T - the type of the input elementsCollectorpublic static <T> Collector<T,?,Set<T>> toUnmodifiableSet()
Collector that fills new unmodifiable Set with input elements.
The returned Collector disallows nulls
and throws NullPointerException if it is presented with a null value.
If elements contain duplicates, an arbitrary element of the duplicates is preserved.T - the type of the input elementsCollectorpublic static <T,K> Collector<T,?,Map<K,T>> toMap(Function<? super T,? extends K> keyMapper)
Collector that fills new Map with input elements.
If the mapped keys contain duplicates, an IllegalStateException is thrown.
Use toMap(Function, Function, BinaryOperator) to handle merging of the values.T - the type of the input elements and the result type of value mapping functionK - the result type of key mapping functionkeyMapper - a mapping function to produce keysCollectortoMap(Function, Function, BinaryOperator)public static <T,K,V> Collector<T,?,Map<K,V>> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper)
Collector that fills new Map with input elements.
If the mapped keys contain duplicates, an IllegalStateException is thrown.
Use toMap(Function, Function, BinaryOperator) to handle merging of the values.T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesCollectortoMap(Function, Function, BinaryOperator)public static <T,K,V,M extends Map<K,V>> Collector<T,?,M> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper, Supplier<M> mapFactory)
Collector that fills new Map with input elements.
If the mapped keys contain duplicates, an IllegalStateException is thrown.
Use toMap(Function, Function, BinaryOperator, Supplier) to handle merging of the values.T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionM - the type of the resulting MapkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesmapFactory - a supplier function that provides new MapCollectortoMap(Function, Function, BinaryOperator, Supplier)public static <T,K,V> Collector<T,?,Map<K,V>> toUnmodifiableMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper)
Collector that fills new unmodifiable Map with input elements.
The returned Collector disallows null keys and values.
If the mapped keys contain duplicates, an IllegalStateException is thrown,
see toUnmodifiableMap(Function, Function, BinaryOperator).T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesCollectortoUnmodifiableMap(Function, Function, BinaryOperator)public static <T,K,V> Collector<T,?,Map<K,V>> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper, BinaryOperator<V> mergeFunction)
Collector that fills new Map with input elements.
If the mapped keys contain duplicates, the value mapping function is applied
to each equal element, and the results are merged using the provided merging function.T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesmergeFunction - a merge function, used to resolve collisions between
values associated with the same keyCollectorpublic static <T,K,V,M extends Map<K,V>> Collector<T,?,M> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<M> mapFactory)
Collector that fills new Map with input elements.
If the mapped keys contain duplicates, the value mapping function is applied
to each equal element, and the results are merged using the provided merging function.T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionM - the type of the resulting MapkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesmergeFunction - a merge function, used to resolve collisions between
values associated with the same keymapFactory - a supplier function that provides new MapCollectorpublic static <T,K,V> Collector<T,?,Map<K,V>> toUnmodifiableMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper, BinaryOperator<V> mergeFunction)
Collector that fills new unmodifiable Map with input elements.
The returned Collector disallows null keys and values.T - the type of the input elementsK - the result type of key mapping functionV - the result type of value mapping functionkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesmergeFunction - a merge function, used to resolve collisions between
values associated with the same keyCollectorpublic static Collector<CharSequence,?,String> joining()
Collector that concatenates input elements into new string.Collectorpublic static Collector<CharSequence,?,String> joining(CharSequence delimiter)
Collector that concatenates input elements into new string.delimiter - the delimiter between each elementCollectorpublic static Collector<CharSequence,?,String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
Collector that concatenates input elements into new string.delimiter - the delimiter between each elementprefix - the prefix of resultsuffix - the suffix of resultCollectorpublic static Collector<CharSequence,?,String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix, String emptyValue)
Collector that concatenates input elements into new string.delimiter - the delimiter between each elementprefix - the prefix of resultsuffix - the suffix of resultemptyValue - the string which replaces empty element if existsCollector@Deprecated public static <T> Collector<T,?,Double> averaging(Function<? super T,Double> mapper)
averagingDouble(com.annimon.stream.function.ToDoubleFunction)Collector that calculates average of input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Double> averagingInt(ToIntFunction<? super T> mapper)
Collector that calculates average of integer-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Double> averagingLong(ToLongFunction<? super T> mapper)
Collector that calculates average of long-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Double> averagingDouble(ToDoubleFunction<? super T> mapper)
Collector that calculates average of double-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Integer> summingInt(ToIntFunction<? super T> mapper)
Collector that summing integer-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Long> summingLong(ToLongFunction<? super T> mapper)
Collector that summing long-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Double> summingDouble(ToDoubleFunction<? super T> mapper)
Collector that summing double-valued input elements.T - the type of the input elementsmapper - the mapping function which extracts value from element to calculate resultCollectorpublic static <T> Collector<T,?,Long> counting()
Collector that counts the number of input elements.T - the type of the input elementsCollectorpublic static <T> Collector<T,?,T> reducing(T identity, BinaryOperator<T> op)
Collector that reduces input elements.T - the type of the input elementsidentity - the initial valueop - the operator to reduce elementsCollectorreducing(java.lang.Object, com.annimon.stream.function.Function, com.annimon.stream.function.BinaryOperator)public static <T,R> Collector<T,?,R> reducing(R identity, Function<? super T,? extends R> mapper, BinaryOperator<R> op)
Collector that reduces input elements.T - the type of the input elementsR - the type of the output elementsidentity - the initial valuemapper - the mapping functionop - the operator to reduce elementsCollectorreducing(java.lang.Object, com.annimon.stream.function.BinaryOperator)public static <T,A,R> Collector<T,?,R> filtering(Predicate<? super T> predicate, Collector<? super T,A,R> downstream)
Collector that filters input elements.T - the type of the input elementsA - the accumulation typeR - the type of the output elementspredicate - a predicate used to filter elementsdownstream - the collector of filtered elementsCollectorpublic static <T,U,A,R> Collector<T,?,R> mapping(Function<? super T,? extends U> mapper, Collector<? super U,A,R> downstream)
Collector that performs mapping before accumulation.T - the type of the input elementsU - the result type of mapping functionA - the accumulation typeR - the result type of collectormapper - a function that performs mapping to input elementsdownstream - the collector of mapped elementsCollectorpublic static <T,U,A,R> Collector<T,?,R> flatMapping(Function<? super T,? extends Stream<? extends U>> mapper, Collector<? super U,A,R> downstream)
Collector that performs flat-mapping before accumulation.T - the type of the input elementsU - the result type of flat-mapping functionA - the accumulation typeR - the result type of collectormapper - a function that performs flat-mapping to input elementsdownstream - the collector of flat-mapped elementsCollectorpublic static <T,A,IR,OR> Collector<T,A,OR> collectingAndThen(Collector<T,A,IR> c, Function<IR,OR> finisher)
Collector that performs additional transformation.T - the type of the input elementsA - the accumulation typeIR - the input type of the transformation functionOR - the output type of the transformation functionc - the input Collectorfinisher - the final transformation functionCollectorpublic static <T,K> Collector<T,?,Map<K,List<T>>> groupingBy(Function<? super T,? extends K> classifier)
Collector that performs grouping operation by given classifier.T - the type of the input elementsK - the type of the keysclassifier - the classifier functionCollectorgroupingBy(com.annimon.stream.function.Function, com.annimon.stream.Collector),
groupingBy(com.annimon.stream.function.Function, com.annimon.stream.function.Supplier, com.annimon.stream.Collector)public static <T,K,A,D> Collector<T,?,Map<K,D>> groupingBy(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream)
Collector that performs grouping operation by given classifier.T - the type of the input elementsK - the type of the keysA - the accumulation typeD - the result type of downstream reductionclassifier - the classifier functiondownstream - the collector of mapped elementsCollectorgroupingBy(com.annimon.stream.function.Function),
groupingBy(com.annimon.stream.function.Function, com.annimon.stream.function.Supplier, com.annimon.stream.Collector)public static <T,K,D,A,M extends Map<K,D>> Collector<T,?,M> groupingBy(Function<? super T,? extends K> classifier, Supplier<M> mapFactory, Collector<? super T,A,D> downstream)
Collector that performs grouping operation by given classifier.T - the type of the input elementsK - the type of the keysA - the accumulation typeD - the result type of downstream reductionM - the type of the resulting Mapclassifier - the classifier functionmapFactory - a supplier function that provides new Mapdownstream - the collector of mapped elementsCollectorgroupingBy(com.annimon.stream.function.Function),
groupingBy(com.annimon.stream.function.Function, com.annimon.stream.Collector)public static <T> Collector<T,?,Map<Boolean,List<T>>> partitioningBy(Predicate<? super T> predicate)
Collector that performs partitioning operation according to a predicate.
The returned Map always contains mappings for both false and true keys.T - the type of the input elementspredicate - a predicate used for classifying input elementsCollectorpublic static <T,D,A> Collector<T,?,Map<Boolean,D>> partitioningBy(Predicate<? super T> predicate, Collector<? super T,A,D> downstream)
Collector that performs partitioning operation according to a predicate.
The returned Map always contains mappings for both false and true keys.T - the type of the input elementsD - the result type of downstream reductionA - the accumulation typepredicate - a predicate used for classifying input elementsdownstream - the collector of partitioned elementsCollectorCopyright © 2018. All rights reserved.