Package 

Class JMap


  • 
    public class JMap
    
                        

    Provides 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 entriesNOTE: without @SafeVarargs, we get a complaint about heappollution, 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 entriesNOTE: without @SafeVarargs, we get a complaint about heappollution, 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 key
        v1 - 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 key
        v1 - the value for the first key
        k2 - the second key
        v2 - 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 key
        v1 - the value for the first key
        k2 - the second key
        v2 - the value for the second key
        k3 - the third key
        v3 - the value for the third key
      • entry

         static <K, V> Map.Entry<K, V> entry(K key, V value)

        A helper to easily create an instance of Map.Entry