java.lang.Object
ushiosan.jvm.collections.UList
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull Collection<T>Combine different lists into a single collectionstatic <T> @NotNull Collection<T>Combine different lists into a single collectionstatic booleanisUnmodifiable(@NotNull Collection<?> collection) Check if the inspected collection supports the modification of its datastatic booleanisUnmodifiable(@NotNull Map<?, ?> map) Check if the inspected collection supports the modification of its datastatic <T> @Unmodifiable List<T>make(@NotNull Collection<T> base) Create an immutable list with all given elements.static <T> @Unmodifiable @NotNull List<T>Create an immutable list with all given elements.static <T> @Unmodifiable List<T>Create an immutable list with all given elements.makeLinked(@NotNull Collection<T> base) Create a linked list with all given elements.makeLinked(@NotNull Iterator<T> iterator) Create a linked list with all given elements.makeLinked(T @NotNull ... elements) Create a linked list with all given elements.makeMutable(@NotNull Collection<T> base) Create a mutable list with all given elements.makeMutable(@NotNull Iterator<T> iterator) Create a mutable list with all given elements.makeMutable(T @NotNull ... elements) Create a mutable list with all given elements.searchIndexes(@NotNull List<T> base, T search) Returns all indices where the searched element is foundConverts one list to another but with a different data type.
-
Method Details
-
make
@SafeVarargs @Contract(pure=true) public static <T> @Unmodifiable List<T> make(T @NotNull ... elements) Create an immutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- an immutable list with all elements
-
make
Create an immutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
base- the base collection content- Returns:
- an immutable list with all elements
-
make
@NotNull public static <T> @Unmodifiable @NotNull List<T> make(@NotNull @NotNull Iterator<T> iterator) Create an immutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
iterator- the base collection content- Returns:
- an immutable list with all elements
-
makeMutable
@SafeVarargs @Contract("_ -> new") @NotNull public static <T> @NotNull List<T> makeMutable(T @NotNull ... elements) Create a mutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- a mutable list with all elements
-
makeMutable
Create a mutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
base- the base collection content- Returns:
- a mutable list with all elements
-
makeMutable
Create a mutable list with all given elements.- Type Parameters:
T- generic type list- Parameters:
iterator- the base collection content- Returns:
- a mutable list with all elements
-
makeLinked
Create a linked list with all given elements.- Type Parameters:
T- generic type list- Parameters:
elements- the elements to insert- Returns:
- a linked list with all elements
-
makeLinked
Create a linked list with all given elements.- Type Parameters:
T- generic type list- Parameters:
base- the base collection content- Returns:
- a linked list with all elements
-
makeLinked
Create a linked list with all given elements.- Type Parameters:
T- generic type list- Parameters:
iterator- the base collection content- Returns:
- a linked list with all elements
-
searchIndexes
@NotNull public static <T> @NotNull List<Integer> searchIndexes(@NotNull @NotNull List<T> base, @Nullable T search) Returns all indices where the searched element is found- Type Parameters:
T- generic object type- Parameters:
base- the base listsearch- the object to search- Returns:
- all indices where the searched object is found
-
transform
@NotNull public static <T,R> @NotNull List<R> transform(@NotNull @NotNull List<T> original, @NotNull @NotNull Function<T, R> mapper) Converts one list to another but with a different data type.- Type Parameters:
T- the original data typeR- the target data type- Parameters:
original- the original list that you want to convertmapper- function in charge of transforming each element of the list- Returns:
- the new list with the converted data
-
isUnmodifiable
Check if the inspected collection supports the modification of its data- Parameters:
collection- the collection of data you want to inspect- Returns:
trueif the collection is immutable orfalseotherwise
-
isUnmodifiable
Check if the inspected collection supports the modification of its data- Parameters:
map- the map of data you want to inspect- Returns:
trueif the collection is immutable orfalseotherwise
-
combine
@SafeVarargs @NotNull public static <T> @NotNull Collection<T> combine(boolean excludeDuplicates, List<T> @NotNull ... lts) Combine different lists into a single collection- Type Parameters:
T- generic collection type- Parameters:
excludeDuplicates- remove all duplicate itemslts- the lists you want to merge- Returns:
- returns a single collection with all the elements of the passed lists
-
combine
Combine different lists into a single collection- Type Parameters:
T- generic collection type- Parameters:
lts- the lists you want to merge- Returns:
- returns a single collection with all the elements of the passed lists
-