Exemplo n.º 1
0
 /**
  * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
  * keys and values are the result of applying the provided mapping functions to the input
  * elements. The generated map is sorted by the specified comparator.
  *
  * <p>If the mapped keys contain duplicates (according to the specified comparator), an {@code
  * IllegalArgumentException} is thrown when the collection operation is performed. (This differs
  * from the {@code Collector} returned by {@link Collectors#toMap(Function, Function)}, which
  * throws an {@code IllegalStateException}.)
  *
  * @since 21.0
  */
 @Beta
 public static <T, K, V> Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
     Comparator<? super K> comparator,
     Function<? super T, ? extends K> keyFunction,
     Function<? super T, ? extends V> valueFunction) {
   return CollectCollectors.toImmutableSortedMap(comparator, keyFunction, valueFunction);
 }
Exemplo n.º 2
0
 /**
  * Returns a {@link Collector} that accumulates elements into an {@code ImmutableBiMap} whose keys
  * and values are the result of applying the provided mapping functions to the input elements.
  * Entries appear in the result {@code ImmutableBiMap} in encounter order.
  *
  * <p>If the mapped keys or values contain duplicates (according to {@link Object#equals(Object)},
  * an {@code IllegalArgumentException} is thrown when the collection operation is performed. (This
  * differs from the {@code Collector} returned by {@link Collectors#toMap(Function, Function)},
  * which throws an {@code IllegalStateException}.)
  *
  * @since 21.0
  */
 @Beta
 public static <T, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
     Function<? super T, ? extends K> keyFunction,
     Function<? super T, ? extends V> valueFunction) {
   return CollectCollectors.toImmutableBiMap(keyFunction, valueFunction);
 }