public class Collectors extends Object
Collectors
class extends on the Collectors
class to provide additional collectors.Constructor and Description |
---|
Collectors() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.function.BinaryOperator<T> |
throwingMerger()
Returns a merge function, suitable for use in
Map.merge() or
toMap() ,
which always throws IllegalStateException . |
static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> |
toIdentityMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper)
Returns a
Collector that accumulates elements into a
IdentityHashMap whose keys and values are the result of applying the
provided mapping functions to the input elements. |
static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> |
toIdentityMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper,
java.util.function.BinaryOperator<U> mergeFunction)
Returns a
Collector that accumulates elements into a
IdentityHashMap whose keys and values are the result of applying the
provided mapping functions to the input elements. |
static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> |
toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper)
Returns a
Collector that accumulates elements into a
LinkedHashMap whose keys and values are the result of applying the
provided mapping functions to the input elements. |
static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> |
toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper,
java.util.function.BinaryOperator<U> mergeFunction)
Returns a
Collector that accumulates elements into a
LinkedHashMap whose keys and values are the result of applying the
provided mapping functions to the input elements. |
static <T,K,U> java.util.stream.Collector<T,?,TreeMap<K,U>> |
toTreeMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper)
|
static <T,K,U> java.util.stream.Collector<T,?,TreeMap<K,U>> |
toTreeMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends U> valueMapper,
java.util.function.BinaryOperator<U> mergeFunction)
|
public static <T> java.util.function.BinaryOperator<T> throwingMerger()
Map.merge()
or
toMap()
,
which always throws IllegalStateException
. This can be used to
enforce the assumption that the elements being collected are distinct.T
- the type of input arguments to the merge functionIllegalStateException
public static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper)
Collector
that accumulates elements into a
LinkedHashMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to
Object.equals(Object)
), an IllegalStateException
is
thrown when the collection operation is performed. If the mapped keys
may have duplicates, use toLinkedMap(Function, Function, BinaryOperator)
instead.
T
- the type of the input elementsK
- the output type of the key mapping functionU
- the output type of the value mapping functionkeyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce valuesCollector
which collects elements into a LinkedHashMap
whose keys and values are the result of applying mapping functions
to the input elementstoLinkedMap(Function, Function, BinaryOperator)
public static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper, java.util.function.BinaryOperator<U> mergeFunction)
Collector
that accumulates elements into a
LinkedHashMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to Object.equals(Object)
),
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 output type of the key mapping functionU
- the output type of the 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 key, as supplied
to Map.merge(Object, Object, BiFunction)
Collector
which collects elements into a LinkedHashMap
whose keys are the result of applying a key mapping function to the
input elements, and whose values are the result of applying a value
mapping function to all input elements equal to the key and combining
them using the merge functiontoLinkedMap(Function, Function)
public static <T,K,U> java.util.stream.Collector<T,?,TreeMap<K,U>> toTreeMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper)
Collector
that accumulates elements into a
TreeMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to
Object.equals(Object)
), an IllegalStateException
is
thrown when the collection operation is performed. If the mapped keys
may have duplicates, use toTreeMap(Function, Function, BinaryOperator)
instead.
T
- the type of the input elementsK
- the output type of the key mapping functionU
- the output type of the value mapping functionkeyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce valuesCollector
which collects elements into a TreeMap
whose keys and values are the result of applying mapping functions
to the input elementstoTreeMap(Function, Function, BinaryOperator)
public static <T,K,U> java.util.stream.Collector<T,?,TreeMap<K,U>> toTreeMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper, java.util.function.BinaryOperator<U> mergeFunction)
Collector
that accumulates elements into a
TreeMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to Object.equals(Object)
),
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 output type of the key mapping functionU
- the output type of the 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 key, as supplied
to Map.merge(Object, Object, BiFunction)
Collector
which collects elements into a TreeMap
whose keys are the result of applying a key mapping function to the
input elements, and whose values are the result of applying a value
mapping function to all input elements equal to the key and combining
them using the merge functiontoTreeMap(Function, Function)
public static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> toIdentityMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper)
Collector
that accumulates elements into a
IdentityHashMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to the ==
operator, an IllegalStateException
is thrown when the collection
operation is performed. If the mapped keys may have duplicates, use
toIdentityMap(Function, Function, BinaryOperator)
instead.
T
- the type of the input elementsK
- the output type of the key mapping functionU
- the output type of the value mapping functionkeyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce valuesCollector
which collects elements into a IdentityHashMap
whose keys and values are the result of applying mapping functions
to the input elementstoIdentityMap(Function, Function, BinaryOperator)
public static <T,K,U> java.util.stream.Collector<T,?,Map<K,U>> toIdentityMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends U> valueMapper, java.util.function.BinaryOperator<U> mergeFunction)
Collector
that accumulates elements into a
IdentityHashMap
whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to the ==
operator), 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 output type of the key mapping functionU
- the output type of the 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 key, as supplied
to Map.merge(Object, Object, BiFunction)
Collector
which collects elements into a IdentityHashMap
whose keys are the result of applying a key mapping function to the
input elements, and whose values are the result of applying a value
mapping function to all input elements equal to the key and combining
them using the merge functiontoLinkedMap(Function, Function)
Copyright (C) 2015-2017 The Helenus Driver Project Authors.