private Object deepCopyObject(Object obj) { if (obj instanceof Map<?, ?>) { Map<?, ?> objMap = (Map<?, ?>) obj; Map<Object, Object> map = Maps.newHashMap(); for (Entry<?, ?> entry : objMap.entrySet()) { map.put(entry.getKey(), deepCopyObject(entry.getValue())); } return map; } else if (obj instanceof List<?>) { List<?> objList = (List<?>) obj; List<Object> list = Lists.newArrayList(); for (Object elem : objList) { list.add(deepCopyObject(elem)); } return list; } else { return obj; } } }
private Object deepCopyObject(Object obj) { if (obj instanceof Map<?, ?>) { Map<?, ?> objMap = (Map<?, ?>) obj; Map<Object, Object> map = Maps.newHashMap(); for (Entry<?, ?> entry : objMap.entrySet()) { map.put(entry.getKey(), deepCopyObject(entry.getValue())); } return map; } else if (obj instanceof List<?>) { List<?> objList = (List<?>) obj; List<Object> list = Lists.newArrayList(); for (Object elem : objList) { list.add(deepCopyObject(elem)); } return list; } else { return obj; } } }
private Object deepCopyObject(Object obj) { if (obj instanceof Map<?, ?>) { Map<?, ?> objMap = (Map<?, ?>) obj; Map<Object, Object> map = Maps.newHashMap(); for (Entry<?, ?> entry : objMap.entrySet()) { map.put(entry.getKey(), deepCopyObject(entry.getValue())); } return map; } else if (obj instanceof List<?>) { List<?> objList = (List<?>) obj; List<Object> list = Lists.newArrayList(); for (Object elem : objList) { list.add(deepCopyObject(elem)); } return list; } else { return obj; } } }
/** * Returns a deep copy of a configuration object. * * @param config The configuration object to copy. * @return A copy of the configuration object. */ @SuppressWarnings("unchecked") protected Map<String, Map<String, Object>> deepCopyConfig( Map<String, Map<String, Object>> config) { return (Map<String, Map<String, Object>>) deepCopyObject(config); }
/** * Returns a deep copy of a configuration object. * * @param config The configuration object to copy. * @return A copy of the configuration object. */ @SuppressWarnings("unchecked") protected Map<String, Map<String, Object>> deepCopyConfig( Map<String, Map<String, Object>> config) { return (Map<String, Map<String, Object>>) deepCopyObject(config); }
/** * Returns a deep copy of a configuration object. * * @param config The configuration object to copy. * @return A copy of the configuration object. */ @SuppressWarnings("unchecked") protected Map<String, Map<String, Object>> deepCopyConfig( Map<String, Map<String, Object>> config) { return (Map<String, Map<String, Object>>) deepCopyObject(config); }