Package io.helidon.common
Class CollectionsHelper
- java.lang.Object
-
- io.helidon.common.CollectionsHelper
-
public abstract class CollectionsHelper extends Object
A set of static methods similar to Java9's List.of(), Set.of() and Map.of().
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>
listOf()
Returns an immutable list containing zero elements.static <T> List<T>
listOf(T... elts)
Returns an unmodifiable list containing the given elements.static <K,V>
Map.Entry<K,V>mapEntry(K k, V v)
Returns anMap.Entry
containing the given key and value.static <K,V>
Map<K,V>mapOf()
Returns an immutable map containing zero mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1)
Create an unmodifiable map containing a single mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2)
Create an unmodifiable map containing 2 mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2, K k3, V v3)
Create an unmodifiable map containing 3 mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
Create an unmodifiable map containing 4 mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
Create an unmodifiable map containing 5 mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
Create an unmodifiable map containing 5 mappings.static <K,V>
Map<K,V>mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)
Create an unmodifiable map containing 5 mappings.static <T> Set<T>
setOf()
Returns an immutable set containing zero elements.static <T> Set<T>
setOf(T... elts)
Create an unmodifiable set containing the given elements.
-
-
-
Method Detail
-
listOf
public static <T> List<T> listOf()
Returns an immutable list containing zero elements.- Type Parameters:
T
- theList
's element type- Returns:
- an empty
List
-
listOf
@SafeVarargs public static <T> List<T> listOf(T... elts)
Returns an unmodifiable list containing the given elements.- Type Parameters:
T
- theList
's element type- Parameters:
elts
- the elements- Returns:
- a
List
containing the specified elements
-
setOf
public static <T> Set<T> setOf()
Returns an immutable set containing zero elements.- Type Parameters:
T
- theSet
's element type- Returns:
- an empty
Set
-
setOf
@SafeVarargs public static <T> Set<T> setOf(T... elts)
Create an unmodifiable set containing the given elements.- Type Parameters:
T
- theSet
's element type- Parameters:
elts
- elements to add- Returns:
- a
Set
containing the specified elements
-
mapEntry
public static <K,V> Map.Entry<K,V> mapEntry(K k, V v)
Returns anMap.Entry
containing the given key and value.- Type Parameters:
K
- the key's typeV
- the value's type- Parameters:
k
- keyv
- value- Returns:
- an
Entry
containing the specified key and value
-
mapOf
public static <K,V> Map<K,V> mapOf()
Returns an immutable map containing zero mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Returns:
- an empty
Map
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1)
Create an unmodifiable map containing a single mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- keyv1
- value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2)
Create an unmodifiable map containing 2 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3)
Create an unmodifiable map containing 3 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second valuek3
- third keyv3
- third value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
Create an unmodifiable map containing 4 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second valuek3
- third keyv3
- third valuek4
- fourth keyv4
- fourth value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
Create an unmodifiable map containing 5 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second valuek3
- third keyv3
- third valuek4
- fourth keyv4
- fourth valuek5
- fifth keyv5
- fifth value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
Create an unmodifiable map containing 5 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second valuek3
- third keyv3
- third valuek4
- fourth keyv4
- fourth valuek5
- fifth keyv5
- fifth valuek6
- sixth keyv6
- sixth value- Returns:
- a
Map
containing the specified mappings
-
mapOf
public static <K,V> Map<K,V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)
Create an unmodifiable map containing 5 mappings.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
k1
- first keyv1
- first valuek2
- second keyv2
- second valuek3
- third keyv3
- third valuek4
- fourth keyv4
- fourth valuek5
- fifth keyv5
- fifth valuek6
- sixth keyv6
- sixth valuek7
- seventh keyv7
- seventh value- Returns:
- a
Map
containing the specified mappings
-
-