io.quarkus.devtools.codestarts.utils.NestedMaps Maven / Gradle / Ivy
package io.quarkus.devtools.codestarts.utils;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
public final class NestedMaps {
private NestedMaps() {
}
@SuppressWarnings("unchecked")
public static Optional getValue(Map data, String path) {
if (!path.contains(".")) {
return Optional.ofNullable((T) data.get(path));
}
int index = path.indexOf(".");
String key = path.substring(0, index);
if (data.get(key) instanceof Map) {
return getValue((Map) data.get(key), path.substring(index + 1));
} else {
return Optional.empty();
}
}
public static Map deepMerge(final Stream