Package net.kyori.adventure.util
Class MonkeyBars
java.lang.Object
net.kyori.adventure.util.MonkeyBars
Collection related utilities.- Since:
- 4.8.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull List<T>Adds an element to the end of the list, or returns a new list.Creates a set from an array of enum constants.static <I,O> @NotNull List<O> nonEmptyArrayToList(@NotNull 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 List<O> toUnmodifiableList(@NotNull Function<I, O> mapper, @NotNull Iterable<? extends I> source) Create a list eagerly mapping the source elements through themapper function.
-
Method Details
-
enumSet
@SafeVarargs @NotNull public static <E extends Enum<E>> @NotNull Set<E> enumSet(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 typeconstants- the enum constants- Returns:
- the set
- Since:
- 4.0.0
-
addOne
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 listnewElement- the element to add- Returns:
- a list
- Since:
- 4.8.0
-
nonEmptyArrayToList
@SafeVarargs @NotNull public static <I,O> @NotNull List<O> nonEmptyArrayToList(@NotNull @NotNull 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 typeO- the output type- Parameters:
mapper- a mapper to convert objectsfirst- the first elementothers- any other elements- Returns:
- an unmodifiable list based on the provided elements
- Since:
- 4.15.0
-
toUnmodifiableList
@NotNull public static <I,O> @NotNull List<O> toUnmodifiableList(@NotNull @NotNull Function<I, O> mapper, @NotNull @NotNull Iterable<? extends I> source) Create a list eagerly mapping the source elements through themapper function.All elements must be non-null before and after mapping.
- Type Parameters:
I- the input typeO- the output type- Parameters:
mapper- element mappersource- input elements- Returns:
- a mapped list
- Since:
- 4.15.0
-