@Test public void testFindAll() { 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 ArrayList<Graph<SimpleNode>.NodePath> retrievedNodes = new ArrayList<Graph<SimpleNode>.NodePath>(); for (final Graph<SimpleNode>.NodePath nodePath : graph.findAll(out, false)) retrievedNodes.add(nodePath); final List<Graph<SimpleNode>.NodePath> expected = new ArrayList<Graph<SimpleNode>.NodePath>(); expected.add(graph.getPath(in, 0, 0)); expected.add(graph.getPath(in, 1, 0)); expected.add(graph.getPath(in2, 0, 0)); Assert.assertEquals(expected, retrievedNodes); }
public Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal) { final Predicate<Graph<Node>.NodePath> selector = equal ? new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.equals(toFind); }; } : new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.getNode() == toFind; }; }; return Iterables.filter(this, selector); }
Graph implements Iterable<Graph<Node>.NodePath> { public Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal) { final Predicate<Graph<Node>.NodePath> selector = equal ? new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.equals(toFind); }; } : new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.getNode() == toFind; }; }; return Iterables.filter(this, selector); } }
Graph implements Iterable<Graph<Node>.NodePath> { public Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal) { final Predicate<Graph<Node>.NodePath> selector = equal ? new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.equals(toFind); }; } : new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.getNode() == toFind; }; }; return Iterables.filter(this, selector); } 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 Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal) { final Predicate<Graph<Node>.NodePath> selector = equal ? new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.equals(toFind); }; } : new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.getNode() == toFind; }; }; return Iterables.filter(this, selector); } 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 Iterable<Graph<Node>.NodePath> findAll(final Node toFind, final boolean equal) { final Predicate<Graph<Node>.NodePath> selector = equal ? new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.equals(toFind); }; } : new Predicate<Graph<Node>.NodePath>() { @Override public boolean apply(final Graph<Node>.NodePath param) { return param.getNode() == toFind; }; }; return Iterables.filter(this, selector); } 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);  }