Node:stream{All => }: rename method

This commit is contained in:
Paul Campbell 2017-02-18 18:16:01 +00:00
parent c772e90d68
commit b644fb9dd8
4 changed files with 7 additions and 7 deletions

View file

@ -249,7 +249,7 @@ public interface Node<T> {
* *
* @return a stream of all the nodes in the tree below this node * @return a stream of all the nodes in the tree below this node
*/ */
Stream<Node<T>> streamAll(); Stream<Node<T>> stream();
/** /**
* Returns a stream of all the node's ancestor nodes. * Returns a stream of all the node's ancestor nodes.

View file

@ -371,9 +371,9 @@ class NodeItem<T> implements Node<T> {
} }
@Override @Override
public Stream<Node<T>> streamAll() { public Stream<Node<T>> stream() {
return Stream.concat(Stream.of(this), getChildren().stream() return Stream.concat(Stream.of(this), getChildren().stream()
.flatMap(Node::streamAll)); .flatMap(Node::stream));
} }
@Override @Override

View file

@ -437,14 +437,14 @@ public class ImmutableNodeItemTest {
Nodes.namedChild("eight", "eight", n6); Nodes.namedChild("eight", "eight", n6);
val immutableRoot = Nodes.asImmutable(node); val immutableRoot = Nodes.asImmutable(node);
//when //when
val result = immutableRoot.streamAll() val result = immutableRoot.stream()
.collect(Collectors.toList()); .collect(Collectors.toList());
//then //then
assertThat(result).as("full tree") assertThat(result).as("full tree")
.hasSize(9); .hasSize(9);
// and // and
assertThat(immutableRoot.getChild("one") assertThat(immutableRoot.getChild("one")
.streamAll() .stream()
.collect(Collectors.toList())).as("sub-tree") .collect(Collectors.toList())).as("sub-tree")
.hasSize(4); .hasSize(4);
} }

View file

@ -920,13 +920,13 @@ public class NodeItemTest {
val n7 = Nodes.namedChild("seven", "seven", n5); val n7 = Nodes.namedChild("seven", "seven", n5);
val n8 = Nodes.namedChild("eight", "eight", n6); val n8 = Nodes.namedChild("eight", "eight", n6);
//when //when
val result = node.streamAll() val result = node.stream()
.collect(Collectors.toList()); .collect(Collectors.toList());
//then //then
assertThat(result).as("full tree") assertThat(result).as("full tree")
.contains(node, n1, n2, n3, n4, n5, n6, n7, n8); .contains(node, n1, n2, n3, n4, n5, n6, n7, n8);
// and // and
assertThat(n1.streamAll() assertThat(n1.stream()
.collect(Collectors.toList())).as("sub-tree") .collect(Collectors.toList())).as("sub-tree")
.containsExactlyInAnyOrder(n1, n3, n5, n7); .containsExactlyInAnyOrder(n1, n3, n5, n7);
} }