/** * Returns a {@code Stream} of every ancestor to this {@code Document}, * beginning with the first ancestor (the root) and ending with the parent * of this {@code Document}. * <p> * This stream can typically not be short-circuited and operations on it * will therefore have a complexity of {@code O(n)}. * * @return a stream of ancestors, from the root to the parent */ default Stream<Document> ancestors() { final List<Document> ancestors = new ArrayList<>(); Document parent = this; while ((parent = parent.getParent().orElse(null)) != null) { ancestors.add(parent); } Collections.reverse(ancestors); return ancestors.stream(); } }
private boolean matches(Document document, String where) { final String lastWhere; if (StringUtils.isBlank(where)) { return true; } else if (where.contains(PATH_SEPARATOR)) { final int index = where.lastIndexOf(PATH_SEPARATOR); final String parentIds = where.substring(0, index).trim(); lastWhere = where.substring(index + PATH_SEPARATOR.length()).trim(); final Optional<? extends Document> parent = document.getParent(); if (parent.isPresent()) { if (!matches(parent.get(), parentIds)) { return false; } } } else { lastWhere = where.trim(); } final int index = lastWhere.indexOf(SET_OPERATOR); final String key, value; if (index == -1) { key = "id"; value = "^" + lastWhere + "$"; } else { key = lastWhere.substring(0, index); value = lastWhere.substring(index + SET_OPERATOR.length()); } return checkIf(document, key, value); }
document.getParent().orElse(null), document.getData(), mainInterface
locate(loaded).collect(toList()).forEach(doc -> { if (delete) { doc.getParent().ifPresent(parent -> { final Collection<? extends Map<String, Object>> coll; if (doc instanceof Dbms) {