@Override public final void put(String key, Object value) { document.put(key, value); } }
/** * Creates and returns a new raw map on a specified key in the specified * document. This might involve creating a new list if no such existed * already. If children already existed on that key, the new one is simply * added to the end of the list. * * @param parent the parent to create it in * @param key the key to create it under * @return the newly creating raw child map */ public static Map<String, Object> newDocument(Document parent, String key) { requireNonNull(parent); requireNonNull(key); final List<Map<String, Object>> children = parent.get(key) .map(DocumentUtil::castToDocumentList) .orElseGet(() -> { final List<Map<String, Object>> list = new CopyOnWriteArrayList<>(); parent.put(key, list); return list; }); final Map<String, Object> child = new ConcurrentSkipListMap<>(); children.add(child); return child; }