Class KiwiMaps


  • public class KiwiMaps
    extends Object
    Utility methods for working with Map instances
    • Constructor Detail

      • KiwiMaps

        public KiwiMaps()
    • Method Detail

      • isNullOrEmpty

        public static <K,​V> boolean isNullOrEmpty​(Map<K,​V> map)
        Checks whether the specified map is null or empty.
        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        map - the map
        Returns:
        true if map is null or empty; false otherwise
      • isNotNullOrEmpty

        public static <K,​V> boolean isNotNullOrEmpty​(Map<K,​V> map)
        Checks whether the specified map is neither null nor empty.
        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        map - the map
        Returns:
        true if map is neither null nor empty; false otherwise
      • newHashMap

        public static <K,​V> Map<K,​V> newHashMap​(Object... items)
        Creates a mutable, HashMap instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:

        key-1, value-1, key-2, value-2, ... , key-N, value-N

        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        items - the items containing keys and values, in pairs
        Returns:
        a new HashMap with data from items
      • newLinkedHashMap

        public static <K,​V> Map<K,​V> newLinkedHashMap​(Object... items)
        Creates a mutable, LinkedHashMap instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:

        key-1, value-1, key-2, value-2, ... , key-N, value-N

        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        items - the items containing keys and values, in pairs
        Returns:
        a new LinkedHashMap with data from items
      • newTreeMap

        public static <K extends Comparable<? super K>,​V> SortedMap<K,​V> newTreeMap​(Object... items)
        Creates a mutable, TreeMap instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:

        key-1, value-1, key-2, value-2, ... , key-N, value-N

        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        items - the items containing keys and values, in pairs
        Returns:
        a new TreeMap with data from items
      • newConcurrentHashMap

        public static <K,​V> ConcurrentMap<K,​V> newConcurrentHashMap​(Object... items)
        Creates a mutable, ConcurrentHashMap instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:

        key-1, value-1, key-2, value-2, ... , key-N, value-N

        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        items - the items containing keys and values, in pairs
        Returns:
        a new ConcurrentHashMap with data from items
      • keyExistsWithNullValue

        public static <K,​V> boolean keyExistsWithNullValue​(Map<K,​V> map,
                                                                 K key)
        Returns true if and only if (1) map is not null or empty, (2) map contains the given key, and (3) the value associated with the given key is null.
        Type Parameters:
        K - the type of the keys in the map
        V - the type of the values in the map
        Parameters:
        map - the map
        key - the key check
        Returns:
        true if and only if (1) map is not null or empty, (2) map contains the given key, and (3) the value associated with the given key is null