java.lang.Object
ushiosan.jvm.collections.UMap
-
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 <K,V> @UnmodifiableView @NotNull Map<K, V> Create a read-only map with all the given elements.static <K,V> @UnmodifiableView @NotNull Map<K, V> Create a read-only map with all the given elements.makeLinked(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.makeLinked(UPair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.makeMutable(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.makeMutable(UPair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.Create a mutable map with all the given elements.Create a mutable map with all the given elements.Converts one map to another but with a different data type.Converts one map to another but with a different data type.
-
Method Details
-
make
@Contract(pure=true) @SafeVarargs @NotNull public static <K,V> @UnmodifiableView @NotNull Map<K,V> make(Map.Entry<K, V> @NotNull ... entries) Create a read-only map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a read-only map with all content
-
make
@Contract(pure=true) @SafeVarargs @NotNull public static <K,V> @UnmodifiableView @NotNull Map<K,V> make(UPair<K, V> @NotNull ... pairs) Create a read-only map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a read-only map with all content
-
makeMutable
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeMutable(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a mutable map with all content
-
makeMutable
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeMutable(UPair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a mutable map with all content
-
makeWeak
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeWeak(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a mutable map with all content
-
makeWeak
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeWeak(UPair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a mutable map with all content
-
makeLinked
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeLinked(Map.Entry<K, V> @NotNull ... entries) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
entries- the elements to insert- Returns:
- a mutable map with all content
-
makeLinked
@SafeVarargs @NotNull public static <K,V> @NotNull Map<K,V> makeLinked(UPair<K, V> @NotNull ... pairs) Create a mutable map with all the given elements.- Type Parameters:
K- key entry typeV- value entry type- Parameters:
pairs- the elements to insert- Returns:
- a mutable map with all content
-
transform
@NotNull public static <K,V, @NotNull Map<KR,KR, VR> VR> transform(@NotNull @NotNull Map<K, V> original, @NotNull @NotNull Function<Map.Entry<K, V>, Map.Entry<KR, VR>> mapper) Converts one map to another but with a different data type.- Type Parameters:
K- base entry key value typeV- base entry value typeKR- output entry key value typeVR- output entry value type- Parameters:
original- the original map that you want to convertmapper- function in charge of transforming each element of the map- Returns:
- the new map with the converted data
-
transformPair
@NotNull public static <K,V, @NotNull Map<KR,KR, VR> VR> transformPair(@NotNull @NotNull Map<K, V> original, @NotNull @NotNull Function<UPair<K, V>, UPair<KR, VR>> mapper) Converts one map to another but with a different data type.- Type Parameters:
K- base entry key value typeV- base entry value typeKR- output entry key value typeVR- output entry value type- Parameters:
original- the original map that you want to convertmapper- function in charge of transforming each element of the map- Returns:
- the new map 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
-