@Test public void testReplace() { final SimpleNode in = new SimpleNode("in"); final SimpleNode a = new SimpleNode("a", in); final SimpleNode b = new SimpleNode("b", in); final SimpleNode out = new SimpleNode("out", a, b); final SimpleNode in2 = new SimpleNode("in2"); in2.outgoings.add(b); final Graph<SimpleNode> graph = new Graph<SimpleNode>(new SimpleNodeModifier(), in, in2); final SimpleNode replacement = new SimpleNode("replaced"); graph.replace(out, replacement, false); final ArrayList<SimpleNode> retrievedNodes = new ArrayList<SimpleNode>(); for (final Graph<SimpleNode>.NodePath nodePath : graph) retrievedNodes.add(nodePath.getNode()); final List<SimpleNode> expected = Arrays.asList(in, a, replacement, b, replacement, in2, b, replacement); Assert.assertEquals(expected, retrievedNodes); }
public void replace(final Node toReplace, final Node replacement, final boolean equal) { for (final NodePath replaceNode : this.findAll(toReplace, equal)) { final int index = replaceNode.getIndex(); final NodePath incoming = replaceNode.getIncoming(); this.replaceChild(incoming, index, replacement); } }
Graph implements Iterable<Graph<Node>.NodePath> { public void replace(final Node toReplace, final Node replacement, final boolean equal) { for (final NodePath replaceNode : this.findAll(toReplace, equal)) { final int index = replaceNode.getIndex(); final NodePath incoming = replaceNode.getIncoming(); this.replaceChild(incoming, index, replacement); } } }
Graph implements Iterable<Graph<Node>.NodePath> { public void replace(final Node toReplace, final Node replacement, final boolean equal) { for (final NodePath replaceNode : this.findAll(toReplace, equal)) { final int index = replaceNode.getIndex(); final NodePath incoming = replaceNode.getIncoming(); this.replaceChild(incoming, index, replacement); } } Graph(final ConnectionModifier<Node> modifier, final List<Node> startNodes);  Graph(final ConnectionModifier<Node> modifier, @SuppressWarnings("unchecked") final Node... startNodes); }
Graph implements Iterable<Graph<Node>.NodePath> { public void replace(final Node toReplace, final Node replacement, final boolean equal) { for (final NodePath replaceNode : this.findAll(toReplace, equal)) { final int index = replaceNode.getIndex(); final NodePath incoming = replaceNode.getIncoming(); this.replaceChild(incoming, index, replacement); } } Graph(final ConnectionModifier<Node> modifier, final List<Node> startNodes);  Graph(final ConnectionModifier<Node> modifier, @SuppressWarnings("unchecked") final Node... startNodes); @SuppressWarnings("rawtypes") @Override boolean equals(final Object obj); Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal); NodePath getPath(final Node startNode, final int... indizes); List<Node> getStartNodes(); @Override int hashCode(); @Override Iterator<Graph<Node>.NodePath> iterator(); void replace(final Node toReplace, final Node replacement, final boolean equal); void replaceChild(final NodePath referencingNode, final int index, final Node replacement); }
Graph implements Iterable<Graph<Node>.NodePath> { public void replace(final Node toReplace, final Node replacement, final boolean equal) { for (final NodePath replaceNode : this.findAll(toReplace, equal)) { final int index = replaceNode.getIndex(); final NodePath incoming = replaceNode.getIncoming(); this.replaceChild(incoming, index, replacement); } } Graph(final ConnectionModifier<Node> modifier, final List<Node> startNodes);  Graph(final ConnectionModifier<Node> modifier, @SuppressWarnings("unchecked") final Node... startNodes); @SuppressWarnings("rawtypes") @Override boolean equals(final Object obj); Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal); NodePath getPath(final Node startNode, final int... indizes); List<Node> getStartNodes(); @Override int hashCode(); @Override Iterator<Graph<Node>.NodePath> iterator(); void replace(final Node toReplace, final Node replacement, final boolean equal); void replaceChild(final NodePath referencingNode, final int index, final Node replacement);  }