Class MonkeyBars


  • public final class MonkeyBars
    extends java.lang.Object
    Collection related utilities.
    Since:
    4.8.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> @NotNull java.util.List<T> addOne​(@NotNull java.util.List<T> oldList, T newElement)
      Adds an element to the end of the list, or returns a new list.
      static <E extends java.lang.Enum<E>>
      @NotNull java.util.Set<E>
      enumSet​(java.lang.Class<E> type, E @NotNull ... constants)
      Creates a set from an array of enum constants.
      static <I,​O>
      @NotNull java.util.List<O>
      nonEmptyArrayToList​(@NotNull java.util.function.Function<I,​O> mapper, I first, @NotNull I @NotNull ... others)
      Create a list based on a first element plus array of additional elements.
      static <I,​O>
      @NotNull java.util.List<O>
      toUnmodifiableList​(@NotNull java.util.function.Function<I,​O> mapper, @NotNull java.lang.Iterable<? extends I> source)
      Create a list eagerly mapping the source elements through the mapper function.
      • Methods inherited from class java.lang.Object

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

      • enumSet

        @SafeVarargs
        @NotNull
        public static <E extends java.lang.Enum<E>> @NotNull java.util.Set<E> enumSet​(java.lang.Class<E> type,
                                                                                      E @NotNull ... constants)
        Creates a set from an array of enum constants.
        Type Parameters:
        E - the enum type
        Parameters:
        type - the enum type
        constants - the enum constants
        Returns:
        the set
        Since:
        4.0.0
      • addOne

        @NotNull
        public static <T> @NotNull java.util.List<T> addOne​(@NotNull
                                                            @NotNull java.util.List<T> oldList,
                                                            T newElement)
        Adds an element to the end of the list, or returns a new list.

        The returned list is unmodifiable.

        Type Parameters:
        T - the element type
        Parameters:
        oldList - the old list
        newElement - the element to add
        Returns:
        a list
        Since:
        4.8.0
      • nonEmptyArrayToList

        @SafeVarargs
        @NotNull
        public static <I,​O> @NotNull java.util.List<O> nonEmptyArrayToList​(@NotNull
                                                                                 @NotNull java.util.function.Function<I,​O> mapper,
                                                                                 @NotNull
                                                                                 I first,
                                                                                 @NotNull
                                                                                 @NotNull I @NotNull ... others)
        Create a list based on a first element plus array of additional elements.

        All elements must be non-null before and after mapping.

        Type Parameters:
        I - the input type
        O - the output type
        Parameters:
        mapper - a mapper to convert objects
        first - the first element
        others - any other elements
        Returns:
        an unmodifiable list based on the provided elements
        Since:
        4.15.0
      • toUnmodifiableList

        @NotNull
        public static <I,​O> @NotNull java.util.List<O> toUnmodifiableList​(@NotNull
                                                                                @NotNull java.util.function.Function<I,​O> mapper,
                                                                                @NotNull
                                                                                @NotNull java.lang.Iterable<? extends I> source)
        Create a list eagerly mapping the source elements through the mapper function.

        All elements must be non-null before and after mapping.

        Type Parameters:
        I - the input type
        O - the output type
        Parameters:
        mapper - element mapper
        source - input elements
        Returns:
        a mapped list
        Since:
        4.15.0