/** Deep copy the tree implemented as map of maps/leafs @param srcTree the source tree @return the tree copy */ @SuppressWarnings("unchecked") static Map<String, Object> copyTree(final Map<String, Object> srcTree) { final Map<String, Object> dstTree = new HashMap<>(srcTree.size()); srcTree.forEach( (k, v) -> dstTree.put(k, v instanceof Map ? copyTree((Map<String, Object>) v) : v) ); return dstTree; }
@SuppressWarnings("unchecked") public BasicConfig( final String pathSep, final Map<String, Object> schema, final Map<String, Object> node ) throws InvalidValuePathException, InvalidValueTypeException, IllegalArgumentException { if(pathSep == null || pathSep.isEmpty()) { throw new IllegalArgumentException("Path separator should not be null/empty"); } this.pathSep = pathSep; this.schema = copyTree(schema); if(node == null || node.size() == 0) { this.node = new HashMap<>(); } else { this.node = new HashMap<>(node.size()); node.forEach(this::putBranch); } }