Class LambdaUtils.Collectors

java.lang.Object
org.ametys.core.util.LambdaUtils.Collectors
Enclosing class:
LambdaUtils

public static class LambdaUtils.Collectors extends Object
Some useful collectors
  • Constructor Details

  • Method Details

    • toLinkedHashMap

      public static <T, K, U> Collector<T,?,Map<K,U>> toLinkedHashMap(Function<? super T,? extends K> keyMapper, 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.

      This is the same as Collectors.toMap(Function, Function), but elements are collected into a LinkedHashMap instead of a HashMap
      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 whose keys and values are the result of applying mapping functions to the input elements
    • withListAccumulation

      public static <T, R> Collector<T,List<T>,R> withListAccumulation(Function<List<T>,R> finisher)
      A convenient method for creating a Collector which accumulates elements into a List, this list being transformed by the provided finisher into the final result.
      Type Parameters:
      T - the type of the input elements
      R - the final result type
      Parameters:
      finisher - The finisher function for the new collector
      Returns:
      the new collector