@Test(expectedExceptions = IllegalArgumentException.class) public void testGetKeysWithException() { MapUtils.getKeys(null, null); }
@SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }
MapUtils { @SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; } }
MapUtils { @SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }  }
MapUtils { @SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }  static boolean containsKey(Map<?, ?> map, Object key); @SuppressWarnings("unchecked") static Set<String> getKeys(Map<String, Object> map, Set<String> keys); static Map<O, List<I>> sortValues(Map<O, List<I>> map, Comparator<I> comparator); static Map<O, List<I>> sortKey(Map<O, List<I>> map, Comparator<O> comparator); }
MapUtils { @SuppressWarnings("unchecked") public static Set<String> getKeys(Map<String, Object> map, Set<String> keys) { if (org.apache.commons.collections4.MapUtils.isEmpty(map)) { throw new IllegalArgumentException("map can not be null"); } if (org.apache.commons.collections4.CollectionUtils.isEmpty(keys)) { keys = new HashSet<String>(); } for (String key : map.keySet()) { if (!keys.contains(key)) { keys.add(key); } Object o = map.get(key); if (o instanceof Map) { getKeys((Map<String, Object>) o, keys); } else if (o instanceof List) { for (Object obj : (List<Object>) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } else if (o instanceof Object[]) { for (Object obj : (Object[]) o) { if (obj instanceof Map) { getKeys((Map<String, Object>) obj, keys); } } } } return keys; }  static boolean containsKey(Map<?, ?> map, Object key); @SuppressWarnings("unchecked") static Set<String> getKeys(Map<String, Object> map, Set<String> keys); static Map<O, List<I>> sortValues(Map<O, List<I>> map, Comparator<I> comparator); static Map<O, List<I>> sortKey(Map<O, List<I>> map, Comparator<O> comparator);  }