Returns an immutable empty <code>NavigableMap</code> if the specified NavigableMap is <code>null</code>, otherwise itself is returned.

@param map
@return
168134
public static <K, V> NavigableMap<K, V> nullToEmpty(final NavigableMap<K, V> map) {
        return map == null ? N.<K, V> emptyNavigableMap() : map;
    }
1313830
public static <K, V> Map<K, V> sortNumberMapByKeyDescending(Map<K, V> map) {
        return sortNumberMapByKeyDescending(map.entrySet());
    }
607716
public static <K, V> Map<K, V> removeNulls(Map<K, V> map) {
        Map<K, V> result = new LinkedHashMap<>();
        map.forEach((k, v) -> {
            if (v != null) {
                result.put(k, v);
            }
        });
        return result;
    }
1250436
private String getReqValue(Map<String, String[]> map, String key) {

        return map.get(key) != null ? map.get(key)[0] : null;
    }
871192
public static String asString(Map<?, ?> map) {
        if (map == null) {
            return NULL;
        }
        StringBuilder builder = new StringBuilder();
        builder.append('{');
        boolean first = true;
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (first) {
                first = false;
            } else {
                builder.append(',');
            }
            builder.append(asString(entry.getKey()))
                   .append(':')
                   .append(asString(entry.getValue()));
        }
        builder.append('}');
        return builder.toString();
    }
1040177
public static Object dotGetNullable(final Map map, final String pathString) {
        return dotGetNullable(map, Object.class, pathString);
    }
1209411
public static <K, V> Map<K, V> toImmutableMap(final Map<K, V> map) {
    switch (map.size()) {
      case 0:
        return Collections.emptyMap();
      case 1:
        final Entry<K, V> entry = map.entrySet().iterator().next();
        return Collections.singletonMap(entry.getKey(), entry.getValue());
      default:
        return Collections.unmodifiableMap(map);
    }
  }
1166254
public static <K, V, M extends Map<K, V>> Optional<V> getOptional(M map,
            K key) {
        return Optional.ofNullable(map).map(m -> m.get(key));
    }
394677
public static String mapToJson(final Map<String, Object> map) {
        try {
            return MAPPER.writeValueAsString(map);
        } catch (JsonProcessingException e) {
            return null;
        }
    }
1118209
public static <K, V> Map<K, V> immutableMapWrap(Map<? extends K, ? extends V> map) {
      return new ImmutableMapWrapper<>(map);
   }
922017
public static Map<String, String> serialize(Map<String, Object> map, String prefix) {
        if (map == null || map.isEmpty()) {
            return Collections.emptyMap();
        }

        Map<String, String> flattened = flatten(map, new HashMap<String, String>(), new ArrayList<String>());

        Map<String, String> result = new HashMap<>();
        for (Map.Entry<String, String> entry : flattened.entrySet()) {
            result.put(prefix + "." + entry.getKey(), entry.getValue());
        }

        return result;
    }
793798
public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
    return new ImmutableMap<>(map);
  }
1236685
public Map<String, String> getStringMap(final Map<String, String> map) {
		final int len = getVInt();
		for (int i = 0; i < len; i++) {
			map.put(getString(), getString());
		}
		return map;
	}
306135
public static <K, V> Map<K, V> nullToEmptyMap(Map<K, V> newValue) {
    if (newValue == null) {
      return new HashMap<>();
    }
    return newValue;
  }
442109
public static Optional<Object> get(final Map map, final Object... path) {
        return get(map, Object.class, path);
    }
954151
public static Object mapToObject(Map<String, String> map, Class<?> c) {

        Method m = null;
        Object obj = null;

        try {
            obj = c.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            log.info("instance create fail : " + c.getName());
            return null;
        }

        for (Map.Entry<String, String> entry : map.entrySet()) {

            if (entry.getValue() == null || entry.getValue().trim().isEmpty()) {
                continue;
            }

            if (entry.getValue().equalsIgnoreCase("undefined")) {
                continue;
            }

            try {
                m = findMethod(c, getSetMethodName(entry.getKey()));
                if (m == null) {
                    log.info("not found mapping method : " + entry.getKey());
                    continue;
                }
                try {
                    m.invoke(obj, castValue(m, m.getParameterTypes()[0], entry.getValue()));
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                    log.info("method invoke error : " + m.getName());
                }
            } catch (SecurityException e) {
                log.info("security exception : " + e.getMessage());
            }
        }

        return obj;
    }
1073489
public static <T> NavigableSet<T> nullToEmpty(final NavigableSet<T> set) {
        return set == null ? N.<T> emptyNavigableSet() : set;
    }