use of com.blackducksoftware.integration.hub.detect.nameversion.metadata.LinkMetadata in project hub-detect by blackducksoftware.
the class LinkedNameVersionNodeBuilder method resolveLinks.
private NameVersionNode resolveLinks(final Set<String> cyclicalNames, final Stack<String> cyclicalStack, final NameVersionNode nameVersionNode) {
if (nameVersionNode == null) {
return null;
}
final String name = nameVersionNode.getName();
if (cyclicalStack.contains(name)) {
cyclicalNames.add(name);
return null;
}
cyclicalStack.push(name);
NameVersionNode resolvedNode = nameVersionNode;
final LinkMetadata linkMetadata = getLinkMetadata(nameVersionNode);
if (linkMetadata != null && linkMetadata.getLinkNode() != null) {
resolvedNode = resolveLinks(cyclicalNames, cyclicalStack, linkMetadata.getLinkNode());
}
if (resolvedNode != null) {
final List<NameVersionNode> resolvedChildren = new ArrayList<>();
for (final NameVersionNode child : resolvedNode.getChildren()) {
final NameVersionNode resolvedChild = resolveLinks(cyclicalNames, cyclicalStack, child);
if (resolvedChild != null) {
resolvedChildren.add(resolvedChild);
}
}
resolvedNode.setChildren(resolvedChildren);
}
cyclicalStack.pop();
return resolvedNode;
}
Aggregations