Class MapUtils


  • public class MapUtils
    extends Object
    Utility for Map.
    Since:
    3.45
    • Constructor Summary

      Constructors 
      Constructor Description
      MapUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void put​(Map<String,​Object> target, String key, boolean value, boolean falseIncluded)
      Put the given key-value pair into the target map when the value is true or falseIncluded is true.
      static void put​(Map<String,​Object> target, String key, int value, boolean zeroIncluded)
      Put the given key-value pair into the target map when the value is not 0 or zeroIncluded is true.
      static void put​(Map<String,​Object> target, String key, long value, boolean zeroIncluded)
      Put the given key-value pair into the target map when the value is not 0 or zeroIncluded is true.
      static void put​(Map<String,​Object> target, String baseKey, TaggedValue[] array, boolean nullIncluded)
      Put "{baseKey}#{tag}" properties into the target map.
      static void put​(Map<String,​Object> target, String key, Map<String,​Object> value, boolean nullIncluded)
      Put the given key-value pair into the target map when the value is not null or nullIncluded is true.
      static <T> void put​(Map<String,​Object> target, String key, T[] array, boolean nullIncluded)
      Put the given key-array pair into the target map when the array is not null or nullIncluded is true.
      static <T> void put​(Map<String,​Object> target, String key, T value, boolean nullIncluded)
      Put the given key-value pair into the target map when the value is not null or nullIncluded is true.
      static void put​(Map<String,​Object> target, Map<String,​Object> map, MapControl control)
      Put the entries in the map into the target map.
      static void putJsonArray​(Map<String,​Object> target, String key, String json, boolean nullIncluded)
      Convert the given json into a List instance and put the instance into the target map with the key.
      static void putJsonObject​(Map<String,​Object> target, String key, String json, boolean nullIncluded)
      Convert the given json into a Map instance and put the instance into the target map with the key.
    • Constructor Detail

      • MapUtils

        public MapUtils()
    • Method Detail

      • put

        public static void put​(Map<String,​Object> target,
                               String key,
                               boolean value,
                               boolean falseIncluded)
        Put the given key-value pair into the target map when the value is true or falseIncluded is true.
      • put

        public static void put​(Map<String,​Object> target,
                               String key,
                               int value,
                               boolean zeroIncluded)
        Put the given key-value pair into the target map when the value is not 0 or zeroIncluded is true.
      • put

        public static void put​(Map<String,​Object> target,
                               String key,
                               long value,
                               boolean zeroIncluded)
        Put the given key-value pair into the target map when the value is not 0 or zeroIncluded is true.
      • put

        public static void put​(Map<String,​Object> target,
                               String key,
                               Map<String,​Object> value,
                               boolean nullIncluded)
        Put the given key-value pair into the target map when the value is not null or nullIncluded is true.
        Since:
        3.95
      • put

        public static <T> void put​(Map<String,​Object> target,
                                   String key,
                                   T value,
                                   boolean nullIncluded)
        Put the given key-value pair into the target map when the value is not null or nullIncluded is true.

        Note that the value of value.toString() is put into the target map, not the value itself.

      • put

        public static <T> void put​(Map<String,​Object> target,
                                   String key,
                                   T[] array,
                                   boolean nullIncluded)
        Put the given key-array pair into the target map when the array is not null or nullIncluded is true.

        Note that elements in the array are converted to String instances by the toString() method and added to a new List instance, and the List instance is put into the target map.

      • put

        public static void put​(Map<String,​Object> target,
                               String baseKey,
                               TaggedValue[] array,
                               boolean nullIncluded)
        Put "{baseKey}#{tag}" properties into the target map.
      • putJsonObject

        public static void putJsonObject​(Map<String,​Object> target,
                                         String key,
                                         String json,
                                         boolean nullIncluded)
        Convert the given json into a Map instance and put the instance into the target map with the key.

        If nullIncluded is true, the key is put into the target map even when the given json is null.

      • putJsonArray

        public static void putJsonArray​(Map<String,​Object> target,
                                        String key,
                                        String json,
                                        boolean nullIncluded)
        Convert the given json into a List instance and put the instance into the target map with the key.

        If nullIncluded is true, the key is put into the target map even when the given json is null.

        Since:
        3.55
      • put

        public static void put​(Map<String,​Object> target,
                               Map<String,​Object> map,
                               MapControl control)
        Put the entries in the map into the target map. When control is null, an instance is internally created by new MapControl() and used.