Class MapUtils


  • public class MapUtils
    extends org.apache.commons.collections.MapUtils
    • Field Summary

      • Fields inherited from class org.apache.commons.collections.MapUtils

        EMPTY_MAP, EMPTY_SORTED_MAP
    • Constructor Summary

      Constructors 
      Constructor Description
      MapUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      void
      addToMultiValueMap​(K key, V value, Map<K,​List<V>> map)  
      static <V,​R extends Map<String,​V>>
      R
      filterMapKey​(R map, String... regex)
      Filter Map keys through regular expression(s).
      static <V,​R extends Map<String,​V>>
      R
      filterMapKeyStartWithIgnoreCase​(R map, String... searchStrings)
      Filter map keys such that each key starts with at least one of the items in the searchStrings array.
      static <K,​V>
      Map.Entry<K,​V>
      getFirstEntry​(Map<K,​V> map)  
      static <K> K getFirstKey​(Map<K,​?> map)  
      static <V> V getFirstValue​(Map<?,​V> map)  
      static <K,​V>
      Map<K,​V>
      mapWithKeysAndValue​(Object... objects)  
      static <K,​V>
      Map<K,​List<V>>
      mapWithKeysAndValueList​(Object... objects)  
      static <K,​V>
      V
      removeFirst​(MultiValueMap<K,​V> map, K key)  
      static <K,​V>
      Map<K,​V>
      sortMapValues​(Map<K,​V> map, Comparator<Map.Entry<K,​V>> comparator)  
      static String toString​(Map map)  
      • Methods inherited from class org.apache.commons.collections.MapUtils

        debugPrint, fixedSizeMap, fixedSizeSortedMap, getBoolean, getBoolean, getBooleanValue, getBooleanValue, getByte, getByte, getByteValue, getByteValue, getDouble, getDouble, getDoubleValue, getDoubleValue, getFloat, getFloat, getFloatValue, getFloatValue, getInteger, getInteger, getIntValue, getIntValue, getLong, getLong, getLongValue, getLongValue, getMap, getMap, getNumber, getNumber, getObject, getObject, getShort, getShort, getShortValue, getShortValue, getString, getString, invertMap, isEmpty, isNotEmpty, lazyMap, lazyMap, lazySortedMap, lazySortedMap, logInfo, multiValueMap, multiValueMap, multiValueMap, orderedMap, predicatedMap, predicatedSortedMap, putAll, safeAddToMap, synchronizedMap, synchronizedSortedMap, toMap, toProperties, transformedMap, transformedSortedMap, typedMap, typedSortedMap, unmodifiableMap, unmodifiableSortedMap, verbosePrint
    • Constructor Detail

      • MapUtils

        public MapUtils()
    • Method Detail

      • addToMultiValueMap

        public static <K,​V> void addToMultiValueMap​(K key,
                                                          V value,
                                                          Map<K,​List<V>> map)
      • getFirstEntry

        public static <K,​V> Map.Entry<K,​V> getFirstEntry​(Map<K,​V> map)
      • getFirstKey

        public static <K> K getFirstKey​(Map<K,​?> map)
      • getFirstValue

        public static <V> V getFirstValue​(Map<?,​V> map)
      • sortMapValues

        public static <K,​V> Map<K,​V> sortMapValues​(Map<K,​V> map,
                                                               Comparator<Map.Entry<K,​V>> comparator)
      • toString

        public static String toString​(Map map)
      • filterMapKey

        public static <V,​R extends Map<String,​V>> R filterMapKey​(R map,
                                                                             String... regex)
        Filter Map keys through regular expression(s). Given a certain key, if String.matches(String) returns true for at least one of the given regular expressions, that key will be retained. In the event that there are no regular expressions to match, the map will retain all of its keys.
        Parameters:
        map - the map to filter
        regex - the regular expression(s) to match the keys to
        Returns:
        the filtered map
      • filterMapKeyStartWithIgnoreCase

        public static <V,​R extends Map<String,​V>> R filterMapKeyStartWithIgnoreCase​(R map,
                                                                                                String... searchStrings)
        Filter map keys such that each key starts with at least one of the items in the searchStrings array.
        Parameters:
        map - the map to filter
        searchStrings - the must-have prefixes of the keys
        Returns:
        the filtered map
      • mapWithKeysAndValue

        public static <K,​V> Map<K,​V> mapWithKeysAndValue​(Object... objects)
      • mapWithKeysAndValueList

        public static <K,​V> Map<K,​List<V>> mapWithKeysAndValueList​(Object... objects)
      • removeFirst

        public static <K,​V> V removeFirst​(MultiValueMap<K,​V> map,
                                                K key)