Class ListUtils

java.lang.Object
com.usatiuk.utils.ListUtils

public class ListUtils extends Object
Utility class for list operations.
  • Constructor Details

    • ListUtils

      public ListUtils()
  • Method Details

    • prependAndMap

      public static <T, T_V> List<T_V> prependAndMap(T_V item, List<T> suffix, Function<T,T_V> suffixFn)
      Prepends an item to a list and maps the rest of the list using a provided function.
      Type Parameters:
      T - The type of the items in the list.
      T_V - The type of the mapped items.
      Parameters:
      item - The item to prepend.
      suffix - The list to append to.
      suffixFn - The function to map the suffix items.
      Returns:
      A new list with the prepended item and mapped suffix items.
    • prepend

      public static <T> List<T> prepend(T item, List<T> suffix)
      Prepends an item to a list.
      Type Parameters:
      T - The type of the items in the list.
      Parameters:
      item - The item to prepend.
      suffix - The list to append to.
      Returns:
      A new list with the prepended item and the original suffix items.
    • map

      public static <T, T_V> List<T_V> map(List<T> suffix, Function<T,T_V> suffixFn)
      Maps a list using a provided function.
      Type Parameters:
      T - The type of the items in the list.
      T_V - The type of the mapped items.
      Parameters:
      suffix - The list to map.
      suffixFn - The function to map the items.
      Returns:
      A new list with the mapped items.