-
- All Implemented Interfaces:
public class JMapProvides helpers for creating a Map easily in place. Java 9 has these features under 'Map' but I scoped them under 'JMap' ('J' for 'Jitsi') to avoid conflicts with java.util.Map. Note that both styles--one taking a vararg of Entries and another taking individual arguments--are in Java 9 and are provided here for convenience.
-
-
Method Summary
Modifier and Type Method Description static <K, V> Map<K, V>ofEntries(Array<Map.Entry<K, V>> entries)Helper function to create a Map from a list of entries NOTE: without @SafeVarargs, we get a complaint about heap pollution, but I don't think it should be an issue here. static <K, V> Map<K, V>of(K k1, V v1)Create a map with the given key and value static <K, V> Map<K, V>of(K k1, V v1, K k2, V v2)Create a map with the given keys and values static <K, V> Map<K, V>of(K k1, V v1, K k2, V v2, K k3, V v3)Create a map with the given keys and values static <K, V> Map.Entry<K, V>entry(K key, V value)A helper to easily create an instance of Map. -
-
Method Detail
-
ofEntries
@SafeVarargs() static <K, V> Map<K, V> ofEntries(Array<Map.Entry<K, V>> entries)
Helper function to create a Map from a list of entries NOTE: without @SafeVarargs, we get a complaint about heap pollution, but I don't think it should be an issue here.
- Parameters:
entries- the entries to add to the map
-
of
static <K, V> Map<K, V> of(K k1, V v1)
Create a map with the given key and value
- Parameters:
k1- the keyv1- the value
-
of
static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2)
Create a map with the given keys and values
- Parameters:
k1- the first keyv1- the value for the first keyk2- the second keyv2- the value for the second key
-
of
static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3)
Create a map with the given keys and values
- Parameters:
k1- the first keyv1- the value for the first keyk2- the second keyv2- the value for the second keyk3- the third keyv3- the value for the third key
-
-
-
-