Class MapCollector

java.lang.Object
org.litebridge.commons.collector.MapCollector

public final class MapCollector extends Object
Utility class for Collectors providing functionality to create LinkedHashMap instances.

This class contains static methods for collecting elements of a Stream into a LinkedHashMap. It uses user-provided mapping functions to determine both the keys and values of the resulting map.

The class is final and contains a private constructor to prevent instantiation, as it is intended to be used solely as a utility class.

  • Method Details

    • toLinkedHashMap

      public static <T, K, U> Collector<T,?,LinkedHashMap<K,U>> toLinkedHashMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
      Returns a Collector that accumulates elements into a LinkedHashMap.
      Type Parameters:
      T - the type of the input elements.
      K - the output type of the key mapping function.
      U - the output type of the value mapping function.
      Parameters:
      keyMapper - a mapping function to produce keys.
      valueMapper - a mapping function to produce values.
      Returns:
      a Collector which collects elements into a LinkedHashMap in insertion order.