Class Lists

java.lang.Object
com.djrapitops.plan.utilities.java.Lists

public class Lists extends Object
Methods that can be used as functional interfaces when dealing with Maps.
  • Method Details

    • create

      public static <V,​ K> List<V> create(K key)
    • builder

      public static <V> Lists.Builder<V> builder(Class<V> ofType)
    • filter

      public static <T extends V,​ V> List<T> filter(Collection<T> original, Predicate<V> keep)
      Efficient replacement for List#stream().filter(keep).collect(Collectors.toList()).
      Type Parameters:
      T - Type of the list objects
      V - Supertype for T if exists, T if not
      Parameters:
      original - Original list
      keep - Condition for keeping on the list
      Returns:
      List with elements in original that keep returned true for.
    • map

      public static <A,​ B> List<B> map(Collection<A> original, Function<A,​B> mapper)
      Efficient replacement for List#stream().map(mapper).collect(Collectors.toList()).
      Type Parameters:
      A - Type of the old list objects
      B - Type of the new list objects
      Parameters:
      original - Original list
      mapper - Function to change object of type A to type B
      Returns:
      List with elements in original that keep returned true for.
    • mapUnique

      public static <A,​ B> Set<B> mapUnique(Collection<A> original, Function<A,​B> mapper)
      Efficient replacement for List#stream().map(mapper).collect(Collectors.toSet()).
      Type Parameters:
      A - Type of the old list objects
      B - Type of the new list objects
      Parameters:
      original - Original list
      mapper - Function to change object of type A to type B
      Returns:
      List with elements in original that keep returned true for.