Class BetterCollectors

java.lang.Object
tech.ydb.yoj.util.lang.BetterCollectors

public final class BetterCollectors extends Object
Better versions of collectors from java.util.stream.Collectors.
  • Method Details

    • toMapNullFriendly

      public static <T, K, U> Collector<T,?,Map<K,U>> toMapNullFriendly(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
      A variant of Collectors.toMap() that allows valueMapper to produce null values for map entries.
      Type Parameters:
      T - the type of input elements
      K - the type of keys
      U - the type of values
      Parameters:
      keyMapper - a mapping function to produce keys
      valueMapper - a mapping function to produce values
      Returns:
      a map produced from the source stream, possibly with null values
      See Also: