@Override public String toString() { return getClass().getSimpleName() + "{" + getName() + "}"; }
@Override public Set<CapabilityScope> getIncludingScopes(CapabilityResolutionContext context) { Map<String, Set<CapabilityScope>> attached = context.getAttachment(attachmentKey); if (attached == null) { attached = new HashMap<>(); Map<String, Set<String>> included = new HashMap<>(); Set<Resource.ResourceEntry> children = context.getResourceRoot().getChildren(type); for (Resource.ResourceEntry resource : children) { String name = resource.getName(); Set<String> includes = getIncludes(resource); included.put(name, includes); attached.put(name, new HashSet<>()); } for (Resource.ResourceEntry resource : children) { String name = resource.getName(); storeIncludes(createIncludedContext(name), name, attached, included); } context.attach(attachmentKey, attached); } Set<CapabilityScope> result = attached.get(value); return result == null ? Collections.emptySet() : result; }
private static void storeIncludes(CapabilityScope includedContext, String key, Map<String, Set<CapabilityScope>> attached, Map<String, Set<String >> included) { for (String includer : included.get(key)) { if (!includedContext.getName().equals(includer)) { // guard against cycles Set<CapabilityScope> includees = attached.get(includer); if (includees != null) { includees.add(includedContext); // Continue up the chain storeIncludes(includedContext, includer, attached, included); } // else 'includer' must have been bogus } } } }
@Override public Set<CapabilityScope> getIncludingScopes(CapabilityResolutionContext context) { Map<String, Set<CapabilityScope>> attached = context.getAttachment(attachmentKey); if (attached == null) { attached = new HashMap<>(); Map<String, Set<String>> included = new HashMap<>(); Set<Resource.ResourceEntry> children = context.getResourceRoot().getChildren(type); for (Resource.ResourceEntry resource : children) { String name = resource.getName(); Set<String> includes = getIncludes(resource); included.put(name, includes); attached.put(name, new HashSet<>()); } for (Resource.ResourceEntry resource : children) { String name = resource.getName(); storeIncludes(createIncludedContext(name), name, attached, included); } context.attach(attachmentKey, attached); } Set<CapabilityScope> result = attached.get(value); return result == null ? Collections.emptySet() : result; }
private static void storeIncludes(CapabilityScope includedContext, String key, Map<String, Set<CapabilityScope>> attached, Map<String, Set<String >> included) { for (String includer : included.get(key)) { if (!includedContext.getName().equals(includer)) { // guard against cycles Set<CapabilityScope> includees = attached.get(includer); if (includees != null) { includees.add(includedContext); // Continue up the chain storeIncludes(includedContext, includer, attached, included); } // else 'includer' must have been bogus } } } }
@Override public String toString() { return getClass().getSimpleName() + "{" + getName() + "}"; }