Class ListUtils

java.lang.Object
com.mendix.utils.ListUtils

public final class ListUtils extends Object
A utility class providing a few shorthand functions for often used mapping functions in Java.
  • Method Details

    • map

      public static <A, B> List<B> map(List<A> list, Function<A,B> mapper)
      This is a shorthand function for list.stream().map(mapper).collect(Collectors.toList()).
      Type Parameters:
      A - The type of elements in the original list
      B - The type of elements in the returning list
      Parameters:
      list - The original list
      mapper - The mapping function to apply to each item in the list
      Returns:
      The new list with the mapping function applied to each item in the list
    • flatMap

      public static <A, B> List<B> flatMap(List<A> list, Function<A,List<B>> mapper)
      This is a shorthand function for list.stream().flatMap(mapper.andThen(Collection::stream)).collect(Collectors.toList()).
      Type Parameters:
      A - The type of elements in the original list
      B - The type of elements in the returning list
      Parameters:
      list - The original list
      mapper - The mapping function to apply to each item in the list
      Returns:
      The new list with the mapping function applied to each item in the list