/** * Creates a new Node by cloning the default node. */ @SuppressWarnings("unchecked") private static <NODE extends LeafNode<?>> NODE createNew(NODE defaultNode) { return (NODE) (defaultNode).clone(); }
/** * Converts a map of String→REAL to String→NODE, where REAL is the underlying value type. */ @SuppressWarnings("unchecked") public static <NODE extends LeafNode<REAL>, REAL> Map<String, NODE> asNodeMap(Map<String, REAL> input, NODE defaultNode) { Map<String, NODE> ret = new LinkedHashMap<>(); for(String key : input.keySet()) { NODE node = (NODE)defaultNode.clone(); node.value = input.get(key); ret.put(key, node); } return Collections.unmodifiableMap(ret); }