private void buildFlattenedMap()

in spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/annotation/ScaYamlConfigChangeParser.java [81:116]


	private void buildFlattenedMap(Map<String, Object> result, Map<String, Object> source, String path) {
		for (Iterator<Map.Entry<String, Object>> itr = source.entrySet().iterator(); itr.hasNext(); ) {
			Map.Entry<String, Object> e = itr.next();
			String key = String.valueOf(e.getKey());
			if (StringUtils.isNotBlank(path)) {
				if (key.startsWith("[")) {
					key = path + key;
				}
				else {
					key = path + '.' + key;
				}
			}
			if (e.getValue() instanceof String) {
				result.put(key, e.getValue());
			}
			else if (e.getValue() instanceof Map) {
				@SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) e.getValue();
				buildFlattenedMap(result, map, key);
			}
			else if (e.getValue() instanceof Collection) {
				@SuppressWarnings("unchecked") Collection<Object> collection = (Collection<Object>) e.getValue();
				if (collection.isEmpty()) {
					result.put(key, "");
				}
				else {
					int count = 0;
					for (Object object : collection) {
						buildFlattenedMap(result, Collections.singletonMap("[" + (count++) + "]", object), key);
					}
				}
			}
			else {
				result.put(key, (e.getValue() != null ? e.getValue() : ""));
			}
		}
	}