import java.util.Map;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+// FIXME: relocate to yang-data-util, where this can have a proper test suite
final class DuplicateFinder {
private final Map<NormalizedNode, DuplicateEntry> identities = new IdentityHashMap<>();
private final Map<NormalizedNode, DuplicateEntry> duplicates = new HashMap<>();
}
private void findDuplicates(final YangInstanceIdentifier path, final NormalizedNode node) {
- final DuplicateEntry i = identities.get(node);
+ final var i = identities.get(node);
if (i == null) {
- final DuplicateEntry d = duplicates.get(node);
+ final var d = duplicates.get(node);
if (d == null) {
- final DuplicateEntry n = new DuplicateEntry(path);
+ final var n = new DuplicateEntry(path);
identities.put(node, n);
duplicates.put(node, n);
} else {
}
if (node instanceof NormalizedNodeContainer<?> container) {
- for (NormalizedNode child : container.body()) {
+ for (var child : container.body()) {
findDuplicates(path.node(child.name()), child);
}
}
}
/**
- * 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.
+ * 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