@Test @SuppressWarnings({"NullableProblems"}) public void testEnsureNoDuplicateEdges_Negative() throws Exception { NodeFactory nodeFactory = new DefaultCharArrayNodeFactory(); List<Node> nodes = Arrays.asList( nodeFactory.createNode("A", null, Collections.<Node>emptyList(), false), nodeFactory.createNode("B", null, Collections.<Node>emptyList(), false), nodeFactory.createNode("B", null, Collections.<Node>emptyList(), false), nodeFactory.createNode("C", null, Collections.<Node>emptyList(), false) ); try { NodeUtil.ensureNoDuplicateEdges(nodes); Assert.fail("Should throw exception"); } catch (IllegalStateException expected) { } }
public static void ensureNoDuplicateEdges(List<Node> nodes) { Set<Character> uniqueChars = new HashSet<Character>(nodes.size()); for (Node node : nodes) { uniqueChars.add(node.getIncomingEdgeFirstCharacter()); } if (nodes.size() != uniqueChars.size()) { throw new IllegalStateException("Duplicate edge detected in list of nodes supplied: " + nodes); } }
NodeUtil { public static void ensureNoDuplicateEdges(List<Node> nodes) { Set<Character> uniqueChars = new HashSet<Character>(nodes.size()); for (Node node : nodes) { uniqueChars.add(node.getIncomingEdgeFirstCharacter()); } if (nodes.size() != uniqueChars.size()) { throw new IllegalStateException("Duplicate edge detected in list of nodes supplied: " + nodes); } } }
NodeUtil { public static void ensureNoDuplicateEdges(List<Node> nodes) { Set<Character> uniqueChars = new HashSet<Character>(nodes.size()); for (Node node : nodes) { uniqueChars.add(node.getIncomingEdgeFirstCharacter()); } if (nodes.size() != uniqueChars.size()) { throw new IllegalStateException("Duplicate edge detected in list of nodes supplied: " + nodes); } } NodeUtil(); }
NodeUtil { public static void ensureNoDuplicateEdges(List<Node> nodes) { Set<Character> uniqueChars = new HashSet<Character>(nodes.size()); for (Node node : nodes) { uniqueChars.add(node.getIncomingEdgeFirstCharacter()); } if (nodes.size() != uniqueChars.size()) { throw new IllegalStateException("Duplicate edge detected in list of nodes supplied: " + nodes); } } NodeUtil(); static int binarySearchForEdge(AtomicReferenceArray<Node> childNodes, Character edgeFirstCharacter); static void ensureNoDuplicateEdges(List<Node> nodes); }
NodeUtil { public static void ensureNoDuplicateEdges(List<Node> nodes) { Set<Character> uniqueChars = new HashSet<Character>(nodes.size()); for (Node node : nodes) { uniqueChars.add(node.getIncomingEdgeFirstCharacter()); } if (nodes.size() != uniqueChars.size()) { throw new IllegalStateException("Duplicate edge detected in list of nodes supplied: " + nodes); } } NodeUtil(); static int binarySearchForEdge(AtomicReferenceArray<Node> childNodes, Character edgeFirstCharacter); static void ensureNoDuplicateEdges(List<Node> nodes);  }