Class ListUtils


  • public final class ListUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> concat​(@Nullable java.util.List<T> ls, T t)  
      static <T> java.util.List<T> concat​(T t, @Nullable java.util.List<T> ls)  
      static <T> java.util.List<T> concatAll​(@Nullable java.util.List<T> ls, @Nullable java.util.List<T> t)  
      static <T> java.util.List<T> flatMap​(@Nullable java.util.List<T> ls, java.util.function.BiFunction<java.lang.Integer,​T,​java.lang.Object> flatMap)  
      static <T> java.util.List<T> flatMap​(@Nullable java.util.List<T> ls, java.util.function.Function<T,​java.lang.Object> flatMap)  
      static <T> java.util.List<T> insertAll​(@Nullable java.util.List<T> ls, int index, @Nullable java.util.List<T> t)  
      static <T> java.util.List<T> insertInOrder​(java.util.List<T> ls, T insert, java.util.Comparator<T> naturalOrdering)
      Insert into as-near of a location representing the natural ordering of the list without assuming the list is already sorted according to its natural ordering AND without changing the position of any other element.
      static <T> java.util.List<T> map​(@Nullable java.util.List<T> ls, java.util.function.BiFunction<java.lang.Integer,​T,​T> map)  
      static <T> java.util.List<T> map​(@Nullable java.util.List<T> ls, java.util.function.UnaryOperator<T> map)  
      static <T> java.util.List<T> mapFirst​(java.util.List<T> ls, java.util.function.UnaryOperator<T> mapFirst)  
      static <T> java.util.List<T> mapLast​(java.util.List<T> ls, java.util.function.UnaryOperator<T> mapLast)  
      static <T> java.util.List<T> mapValues​(org.graalvm.polyglot.Value values, java.util.function.BiFunction<java.lang.Integer,​org.graalvm.polyglot.Value,​T> mapFn)  
      static <T> @Nullable java.util.List<T> nullIfEmpty​(java.util.List<T> ls)  
      • Methods inherited from class java.lang.Object

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

      • insertInOrder

        public static <T> java.util.List<T> insertInOrder​(java.util.List<T> ls,
                                                          T insert,
                                                          java.util.Comparator<T> naturalOrdering)
        Insert into as-near of a location representing the natural ordering of the list without assuming the list is already sorted according to its natural ordering AND without changing the position of any other element. This provides a means of both inserting in a natural order but also making the least invasive change.
        Type Parameters:
        T - The type of elements in the list.
        Parameters:
        ls - The original list, which may not be ordered.
        insert - The element to add.
        naturalOrdering - The natural or idiomatic ordering of the list.
        Returns:
        A new list with the element inserted in an approximately ordered place.
      • mapLast

        public static <T> java.util.List<T> mapLast​(java.util.List<T> ls,
                                                    java.util.function.UnaryOperator<T> mapLast)
      • mapFirst

        public static <T> java.util.List<T> mapFirst​(java.util.List<T> ls,
                                                     java.util.function.UnaryOperator<T> mapFirst)
      • mapValues

        public static <T> java.util.List<T> mapValues​(org.graalvm.polyglot.Value values,
                                                      java.util.function.BiFunction<java.lang.Integer,​org.graalvm.polyglot.Value,​T> mapFn)
      • map

        public static <T> java.util.List<T> map​(@Nullable
                                                @Nullable java.util.List<T> ls,
                                                java.util.function.BiFunction<java.lang.Integer,​T,​T> map)
      • map

        public static <T> java.util.List<T> map​(@Nullable
                                                @Nullable java.util.List<T> ls,
                                                java.util.function.UnaryOperator<T> map)
      • flatMap

        public static <T> java.util.List<T> flatMap​(@Nullable
                                                    @Nullable java.util.List<T> ls,
                                                    java.util.function.BiFunction<java.lang.Integer,​T,​java.lang.Object> flatMap)
      • flatMap

        public static <T> java.util.List<T> flatMap​(@Nullable
                                                    @Nullable java.util.List<T> ls,
                                                    java.util.function.Function<T,​java.lang.Object> flatMap)
      • nullIfEmpty

        @Nullable
        public static <T> @Nullable java.util.List<T> nullIfEmpty​(java.util.List<T> ls)