Package co.crystaldev.alpinecore.util
Class CollectionUtils
java.lang.Object
co.crystaldev.alpinecore.util.CollectionUtils
Utility for instantiating commonly used
Collection
s with concise
and clean syntax.- Since:
- 0.1.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull LinkedList<T>
linkedList
(@NotNull T... items) Creates a new ordered list with the specified objects.static <K,
V> @NotNull LinkedHashMap<K, V> Creates a new ordered map with the specified objects.static <T> @NotNull LinkedHashSet<T>
linkedSet
(@NotNull T... items) Creates a new ordered list with the specified objects.static <T> @NotNull List<T>
list
(@NotNull T... items) Creates a new list with the specified objects.static <K,
V> @NotNull Map<K, V> Creates a new map with the specified objects.static <T> @NotNull Set<T>
set
(@NotNull T... items) Creates a new set with the specified objects.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
list
@SafeVarargs @NotNull @Contract("null -> fail") public static <T> @NotNull List<T> list(@NotNull @NotNull T... items) Creates a new list with the specified objects.This method makes no assertion as to the ordering of the list. For an ordered list, use
linkedList(Object[])
.- Type Parameters:
T
- the type of the elements in the list- Parameters:
items
- the objects to add to the list- Returns:
- the list
- See Also:
-
linkedList
@SafeVarargs @NotNull @Contract("null -> fail") public static <T> @NotNull LinkedList<T> linkedList(@NotNull @NotNull T... items) Creates a new ordered list with the specified objects.- Type Parameters:
T
- the type of the elements in the list- Parameters:
items
- the objects to add to the list- Returns:
- the list
- See Also:
-
set
@SafeVarargs @NotNull @Contract("null -> fail") public static <T> @NotNull Set<T> set(@NotNull @NotNull T... items) Creates a new set with the specified objects.This method makes no assertion as to the ordering of the list. For an ordered list, use
linkedSet(Object[])
.- Type Parameters:
T
- the type of the elements in the set- Parameters:
items
- the objects to add to the set- Returns:
- the set
- See Also:
-
linkedSet
@SafeVarargs @NotNull @Contract("null -> fail") public static <T> @NotNull LinkedHashSet<T> linkedSet(@NotNull @NotNull T... items) Creates a new ordered list with the specified objects.- Type Parameters:
T
- the type of the elements in the set- Parameters:
items
- the objects to add to the set- Returns:
- the set
- See Also:
-
map
@NotNull public static <K,V> @NotNull Map<K,V> map(@NotNull K firstKey, @NotNull V firstValue, @NotNull @NotNull Object... items) Creates a new map with the specified objects.This method makes no assertion as to the ordering of the map. For an ordered map, use
linkedMap(Object, Object, Object...)
.Varargs should be specified by alternating keys and values.
If the number of varargs is odd, the method will quietly ignore them.
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the keys and values to add to the map- Returns:
- the map
- See Also:
-
linkedMap
@NotNull public static <K,V> @NotNull LinkedHashMap<K,V> linkedMap(@NotNull K firstKey, @NotNull V firstValue, @NotNull @NotNull Object... items) Creates a new ordered map with the specified objects.Varargs should be specified by alternating keys and values.
If the number of varargs is odd, the method will quietly ignore them.
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the keys and values to add to the map- Returns:
- the map
- See Also:
-