/** * Recursively scan a {@link NormalizedNode} instance and its children and * produce a collection of {@link DuplicateEntry} objects. Each holds the * original definition path and a list of hard/softlinks. * * @param node Root node, may not be null. * @return List of entries */ static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(final NormalizedNode<?, ?> node) { final DuplicateFinder finder = new DuplicateFinder(); finder.findDuplicates(YangInstanceIdentifier.EMPTY, node); return finder.identities; } }
/** * Recursively scan a {@link NormalizedNode} instance and its children and * produce a collection of {@link DuplicateEntry} objects. Each holds the * original definition path and a list of hard/softlinks. * * @param node Root node, may not be null. * @return List of entries */ static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(final NormalizedNode<?, ?> node) { final DuplicateFinder finder = new DuplicateFinder(); finder.findDuplicates(YangInstanceIdentifier.EMPTY, node); return finder.identities; } }
/** * Find duplicate NormalizedNode instances within a subtree. Duplicates are those, which compare * as equal, but do not refer to the same object. * * @param node A normalized node subtree, may not be null * @return A Map of NormalizedNode/DuplicateEntry relationships. */ public static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(@Nonnull final NormalizedNode<?, ?> node) { return Maps.filterValues(DuplicateFinder.findDuplicates(node), input -> !input.getDuplicates().isEmpty()); } }
/** * Find duplicate NormalizedNode instances within a subtree. Duplicates are those, which compare * as equal, but do not refer to the same object. * * @param node A normalized node subtree, may not be null * @return A Map of NormalizedNode/DuplicateEntry relationships. */ public static Map<NormalizedNode<?, ?>, DuplicateEntry> findDuplicates(@Nonnull final NormalizedNode<?, ?> node) { return Maps.filterValues(DuplicateFinder.findDuplicates(node), input -> !input.getDuplicates().isEmpty()); } }
private void findDuplicates(final YangInstanceIdentifier path, final NormalizedNode<?, ?> node) { final DuplicateEntry i = identities.get(node); if (i == null) { final DuplicateEntry d = duplicates.get(node); if (d == null) { final DuplicateEntry n = new DuplicateEntry(path); identities.put(node, n); duplicates.put(node, n); } else { d.addDuplicate(path); } if (node instanceof NormalizedNodeContainer<?, ?, ?>) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) node; for (NormalizedNode<?, ?> c : container.getValue()) { findDuplicates(path.node(c.getIdentifier()), c); } } } else { i.addHardLink(path); } }
private void findDuplicates(final YangInstanceIdentifier path, final NormalizedNode<?, ?> node) { final DuplicateEntry i = identities.get(node); if (i == null) { final DuplicateEntry d = duplicates.get(node); if (d == null) { final DuplicateEntry n = new DuplicateEntry(path); identities.put(node, n); duplicates.put(node, n); } else { d.addDuplicate(path); } if (node instanceof NormalizedNodeContainer<?, ?, ?>) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) node; for (NormalizedNode<?, ?> c : container.getValue()) { findDuplicates(path.node(c.getIdentifier()), c); } } } else { i.addHardLink(path); } }