Source:
static Map<String, Set<String>> getChildAddresses(final OperationContext context, final PathAddress addr, final ImmutableManagementResourceRegistration registry, Resource resource, final String validChildType) { Map<String, Set<String>> result = new HashMap<>(); for (String childType : registry.getChildNames(PathAddress.EMPTY_ADDRESS)) { if ((validChildType == null) || validChildType.equals(childType)) { result.put(childType, new LinkedHashSet<>(resource.getChildrenNames(childType))); } } Set<PathElement> paths = registry.getChildAddresses(PathAddress.EMPTY_ADDRESS); for (PathElement path : paths) { String childType = path.getKey(); if ((validChildType == null) || validChildType.equals(childType)) { Set<String> children = result.get(childType); if (children == null) { children = new LinkedHashSet<>(); result.put(childType, children); } ImmutableManagementResourceRegistration childRegistration = registry.getSubModel(PathAddress.pathAddress(path)); AliasEntry aliasEntry = childRegistration.getAliasEntry(); if (aliasEntry != null) { PathAddress childAddr = addr.append(path); PathAddress target = aliasEntry.convertToTargetAddress(childAddr, AliasContext.create(childAddr, context)); assert !childAddr.equals(target) : "Alias was not translated"; PathAddress targetParent = target.getParent(); Resource parentResource = context.readResourceFromRoot(targetParent, false); if (parentResource != null) { PathElement targetElement = target.getLastElement(); if (targetElement.isWildcard()) { children.addAll(parentResource.getChildrenNames(targetElement.getKey())); } else if (parentResource.hasChild(targetElement)) { children.add(path.getValue()); } } } if (!path.isWildcard() && childRegistration.isRemote()) { children.add(path.getValue()); } } } return result; }

Target:
static Map<String, Set<String>> getChildAddresses(final OperationContext context, final PathAddress addr, final ImmutableManagementResourceRegistration registry, Resource resource, final String validChildType) { Map<String, Set<String>> result = new HashMap<>(); Predicate<String> validChildTypeFilter = childType -> (validChildType == null) || validChildType.equals(childType); if (resource != null) { registry.getChildNames(PathAddress.EMPTY_ADDRESS).stream() .filter(validChildTypeFilter) .forEach(childType -> result.put(childType, new LinkedHashSet<>(resource.getChildrenNames(childType).stream() .filter(child -> registry.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childType, child))) != null) .collect(Collectors.toList())))); } Set<PathElement> paths = registry.getChildAddresses(PathAddress.EMPTY_ADDRESS); for (PathElement path : paths) { String childType = path.getKey(); if (validChildTypeFilter.test(childType)) { Set<String> children = result.get(childType); if (children == null) { children = new LinkedHashSet<>(); result.put(childType, children); } ImmutableManagementResourceRegistration childRegistration = registry.getSubModel(PathAddress.pathAddress(path)); if (childRegistration != null) { AliasEntry aliasEntry = childRegistration.getAliasEntry(); if (aliasEntry != null) { PathAddress childAddr = addr.append(path); PathAddress target = aliasEntry.convertToTargetAddress(childAddr, AliasContext.create(childAddr, context)); assert !childAddr.equals(target) : "Alias was not translated"; PathAddress targetParent = target.getParent(); Resource parentResource = context.readResourceFromRoot(targetParent, false); if (parentResource != null) { PathElement targetElement = target.getLastElement(); if (targetElement.isWildcard()) { children.addAll(parentResource.getChildrenNames(targetElement.getKey())); } else if (parentResource.hasChild(targetElement)) { children.add(path.getValue()); } } } if (!path.isWildcard() && childRegistration.isRemote()) { children.add(path.getValue()); } } } } return result; }