@SuppressWarnings("unchecked") private FullNode doGet(RelativePath path) { CanonicalPath pathToElement = rootEntity.getPath().modified().extend(path.getPath()).get(); try { FullNode cached = cache.get(pathToElement); if (cached != null) { return cached == FullNode.EMPTY ? null : cached; } Entity<Entity.Blueprint, ?> entity = (Entity<Entity.Blueprint, ?>) inventory.inspect(pathToElement, ResolvableToSingle.class).entity(); Entity.Blueprint b = Inventory.asBlueprint(entity); FullNode ret = new FullNode(b, entity); cache.put(entity.getPath(), ret); return ret; } catch (EntityNotFoundException e) { cache.put(pathToElement, FullNode.EMPTY); return null; } } };
@Override public Stream<FullNode> getAllChildNodes(RelativePath parent) { CanonicalPath absoluteParent = rootEntity.getPath().modified().extend(parent.getPath()).get(); Query q = Query.path().with(With.path(absoluteParent), Related.by(contains)).get(); @SuppressWarnings("rawtypes") Page<Entity> results = inventory.execute(q, Entity.class, Pager.none()); return StreamSupport.stream(results.spliterator(), false) .map(e -> { @SuppressWarnings("unchecked") FullNode n = new FullNode((Entity.Blueprint) Inventory.asBlueprint(e), e); cache.put(e.getPath(), n); return n; }) .sorted(ENTITY_ORDER) .onClose(results::close); }
IntermediateHashContext progress(Entity.Blueprint bl) { SegmentType st = Blueprint.getSegmentTypeOf(bl); String id = bl.getId(); return new IntermediateHashContext(origin == null ? null : origin.modified().extend(st, id).get(), root.modified().extend(st, id).get()); } }
@Override public <EE extends Entity<? extends BB, ?>, BB extends Entity.Blueprint> Stream<FullNode> getChildNodes(RelativePath parent, Class<EE> childType) { CanonicalPath absoluteParent = rootEntity.getPath().modified().extend(parent.getPath()).get(); SegmentType parentType = absoluteParent.getSegment().getElementType();