Class Lists


  • public class Lists
    extends java.lang.Object
    Methods that can be used as functional interfaces when dealing with Maps.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Lists.Builder<V>  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <V> Lists.Builder<V> builder​(java.lang.Class<V> ofType)  
      static <V,​K>
      java.util.List<V>
      create​(K key)  
      static <T extends V,​V>
      java.util.List<T>
      filter​(java.util.Collection<T> original, java.util.function.Predicate<V> keep)
      Efficient replacement for List#stream().filter(keep).collect(Collectors.toList()).
      static <A,​B>
      java.util.List<B>
      map​(java.util.Collection<A> original, java.util.function.Function<A,​B> mapper)
      Efficient replacement for List#stream().map(mapper).collect(Collectors.toList()).
      static <A,​B>
      java.util.Set<B>
      mapUnique​(java.util.Collection<A> original, java.util.function.Function<A,​B> mapper)
      Efficient replacement for List#stream().map(mapper).collect(Collectors.toSet()).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

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

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

        public static <T extends V,​V> java.util.List<T> filter​(java.util.Collection<T> original,
                                                                     java.util.function.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> java.util.List<B> map​(java.util.Collection<A> original,
                                                        java.util.function.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> java.util.Set<B> mapUnique​(java.util.Collection<A> original,
                                                             java.util.function.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.