@Override public List<Resource.Blueprint> getResources(RelativePath rootPath, Resource.Blueprint parentResource) { RelativePath p = rootPath.modified().extend(SegmentType.r, parentResource.getId()).get() .slide(1, 0); try (Stream<Resource.Blueprint> s = structure.getChildren(p, Resource.class)) { return s.collect(toList()); } }
@Override public List<Metric.Blueprint> getResourceMetrics(RelativePath rootPath, Resource.Blueprint parentResource) { RelativePath p = rootPath.modified().extend(SegmentType.r, parentResource.getId()).get() .slide(1, 0); try (Stream<Metric.Blueprint> s = structure.getChildren(p, Metric.class)) { return s.collect(toList()); } }
RelativePath strippedStructurePath = structurePath.slide(structureRoot.getDepth(), 0); RelativePath newStructurePath = myPath.modified().extend(strippedStructurePath.getPath()).get();
@Override public DataEntity.Blueprint<?> getReturnType(RelativePath rootResourceType, OperationType.Blueprint ot) { RelativePath.Extender p = rootResourceType.modified().extend(SegmentType.ot, ot.getId()).get() .slide(1, 0).modified(); return getData(p, returnType); } };
@Override public DataEntity.Blueprint<?> getConfiguration(RelativePath rootPath, Resource.Blueprint parentResource) { RelativePath.Extender resourcePath = rootPath.modified() .extend(SegmentType.r, parentResource.getId()).get().slide(1, 0).modified(); return getData(resourcePath, configuration); }
@Override public DataEntity.Blueprint<?> getConnectionConfiguration(RelativePath root, Resource.Blueprint parentResource) { RelativePath.Extender resourcePath = root.modified().extend(SegmentType.r, parentResource.getId()) .get().slide(1, 0).modified(); return getData(resourcePath, connectionConfiguration); }
@Override public DataEntity.Blueprint<?> getParameterTypes(RelativePath rootResourceType, OperationType.Blueprint ot) { RelativePath.Extender p = rootResourceType.modified().extend(SegmentType.ot, ot.getId()).get() .slide(1, 0).modified(); return getData(p, parameterTypes); }
static IntermediateHashResult treeOf(InventoryStructure<?> inventory, CanonicalPath rootPath, boolean computeIdentity, boolean computeContent, boolean computeSync, Consumer<IntermediateHashContext> onStartChild, BiConsumer<IntermediateHashContext, IntermediateHashResult> onEndChild, Function<RelativePath, Hashes> hashLoader) { ComputeHash.DigestComputingWriter wrt = new ComputeHash.DigestComputingWriter(ComputeHash.newDigest()); ComputeHash.HashConstructor ctor = new ComputeHash.HashConstructor(wrt) { @Override public void startChild(ComputeHash.IntermediateHashContext context) { super.startChild(context); onStartChild.accept(context); } @Override public void endChild(ComputeHash.IntermediateHashContext ctx, ComputeHash.IntermediateHashResult result) { super.endChild(ctx, result); onEndChild.accept(ctx, result); } }; return computeHash(rootPath, inventory.getRoot(), ComputeHash.HashableView.of(inventory), ctor, computeIdentity, computeContent, computeSync, //we don't want the root element in the relative paths of the children so that they are easily //appendable to the root. (rp) -> rp.slide(1, 0), hashLoader ); }