@Test public void flatNestedLinkedHashMap() { assertEquals(forTest.flatNestedLinkedHashMap(), 3); }
@SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap) { LinkedHashMap<String, Object> flatNestedMap = new LinkedHashMap<String, Object>(); String prefixKey = notation != null ? notation + "." : ""; for (Map.Entry<String, Object> entry : nestedMap.entrySet()) { if (entry.getValue() instanceof String || entry.getValue() instanceof Long || entry.getValue() instanceof Integer || entry.getValue() instanceof Float || entry.getValue() instanceof Double) { flatNestedMap.put(prefixKey + entry.getKey(), entry.getValue()); } if (entry.getValue() instanceof Map) { flatNestedMap.putAll(flatNestedMap(prefixKey + entry.getKey(), (Map<String, Object>) entry.getValue())); } if (entry.getValue() instanceof ArrayList) { Gson gson = new Gson(); flatNestedMap.put("list",gson.toJson(entry.getValue())); } } return flatNestedMap; }
CommonUtils { @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap) { LinkedHashMap<String, Object> flatNestedMap = new LinkedHashMap<String, Object>(); String prefixKey = notation != null ? notation + "." : ""; for (Map.Entry<String, Object> entry : nestedMap.entrySet()) { if (entry.getValue() instanceof String || entry.getValue() instanceof Long || entry.getValue() instanceof Integer || entry.getValue() instanceof Float || entry.getValue() instanceof Double) { flatNestedMap.put(prefixKey + entry.getKey(), entry.getValue()); } if (entry.getValue() instanceof Map) { flatNestedMap.putAll(flatNestedMap(prefixKey + entry.getKey(), (Map<String, Object>) entry.getValue())); } if (entry.getValue() instanceof ArrayList) { Gson gson = new Gson(); flatNestedMap.put("list",gson.toJson(entry.getValue())); } } return flatNestedMap; } }
CommonUtils { @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap) { LinkedHashMap<String, Object> flatNestedMap = new LinkedHashMap<String, Object>(); String prefixKey = notation != null ? notation + "." : ""; for (Map.Entry<String, Object> entry : nestedMap.entrySet()) { if (entry.getValue() instanceof String || entry.getValue() instanceof Long || entry.getValue() instanceof Integer || entry.getValue() instanceof Float || entry.getValue() instanceof Double) { flatNestedMap.put(prefixKey + entry.getKey(), entry.getValue()); } if (entry.getValue() instanceof Map) { flatNestedMap.putAll(flatNestedMap(prefixKey + entry.getKey(), (Map<String, Object>) entry.getValue())); } if (entry.getValue() instanceof ArrayList) { Gson gson = new Gson(); flatNestedMap.put("list",gson.toJson(entry.getValue())); } } return flatNestedMap; } private  CommonUtils(); }
CommonUtils { @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap) { LinkedHashMap<String, Object> flatNestedMap = new LinkedHashMap<String, Object>(); String prefixKey = notation != null ? notation + "." : ""; for (Map.Entry<String, Object> entry : nestedMap.entrySet()) { if (entry.getValue() instanceof String || entry.getValue() instanceof Long || entry.getValue() instanceof Integer || entry.getValue() instanceof Float || entry.getValue() instanceof Double) { flatNestedMap.put(prefixKey + entry.getKey(), entry.getValue()); } if (entry.getValue() instanceof Map) { flatNestedMap.putAll(flatNestedMap(prefixKey + entry.getKey(), (Map<String, Object>) entry.getValue())); } if (entry.getValue() instanceof ArrayList) { Gson gson = new Gson(); flatNestedMap.put("list",gson.toJson(entry.getValue())); } } return flatNestedMap; } private  CommonUtils(); @SuppressWarnings("unchecked") static Map<String, Object> flatNestedMap(String notation, Map<String, Object> nestedMap); static String buildErrorResponse(Exception e); static String convertAttributetoKeyword(String attributeName); @SuppressWarnings("unchecked") static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap); static Object filterMatchingCollectionElements(Object obj, String pattern, boolean retainInsteadOfFilter); static SSLContext createNoSSLContext(); static String capitailizeWord(String mainStr); static String getEnvironmentForTag(String key); }
CommonUtils { @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap) { LinkedHashMap<String, Object> flatNestedMap = new LinkedHashMap<String, Object>(); String prefixKey = notation != null ? notation + "." : ""; for (Map.Entry<String, Object> entry : nestedMap.entrySet()) { if (entry.getValue() instanceof String || entry.getValue() instanceof Long || entry.getValue() instanceof Integer || entry.getValue() instanceof Float || entry.getValue() instanceof Double) { flatNestedMap.put(prefixKey + entry.getKey(), entry.getValue()); } if (entry.getValue() instanceof Map) { flatNestedMap.putAll(flatNestedMap(prefixKey + entry.getKey(), (Map<String, Object>) entry.getValue())); } if (entry.getValue() instanceof ArrayList) { Gson gson = new Gson(); flatNestedMap.put("list",gson.toJson(entry.getValue())); } } return flatNestedMap; } private  CommonUtils(); @SuppressWarnings("unchecked") static Map<String, Object> flatNestedMap(String notation, Map<String, Object> nestedMap); static String buildErrorResponse(Exception e); static String convertAttributetoKeyword(String attributeName); @SuppressWarnings("unchecked") static LinkedHashMap<String, Object> flatNestedLinkedHashMap(String notation, Map<String, Object> nestedMap); static Object filterMatchingCollectionElements(Object obj, String pattern, boolean retainInsteadOfFilter); static SSLContext createNoSSLContext(); static String capitailizeWord(String mainStr); static String getEnvironmentForTag(String key);  }