Package io.cucumber.plugin.event
Interface Node
-
- All Known Subinterfaces:
Node.Container<T>,Node.Example,Node.Examples,Node.Feature,Node.Rule,Node.Scenario,Node.ScenarioOutline
@API(status=EXPERIMENTAL) public interface NodeA node in a source file.A node has a location, a keyword and name. The keyword and name are both optional (e.g.
Node.Exampleand blank scenario names).Nodes are organized in a tree like structure where
Node.Containernodes contain yet more nodes.A node can be linked to a
TestCasebygetLocation(). ThefindPathTo(Predicate)method can be used to find a path from the root node to a node with the same location as a test case.Location location = testCase.getLocation();Predicate<Node> withLocation = candidate -> location.equals(candidate.getLocation());Optional<List<Node>> path = node.findPathTo(withLocation);
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceNode.Container<T extends Node>static interfaceNode.ExampleAn example has no keyword but always a name.static interfaceNode.ExamplesAn examples section has a keyword and optionally a name.static interfaceNode.FeatureA feature has a keyword and optionally a name.static interfaceNode.RuleA rule has a keyword and optionally a name.static interfaceNode.ScenarioA scenario has a keyword and optionally a name.static interfaceNode.ScenarioOutlineA scenario outline has a keyword and optionally a name.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Optional<List<Node>>findPathTo(Predicate<Node> predicate)Finds a path down tree starting at this node to the first node that matches the predicate using depth first search.Optional<String>getKeyword()LocationgetLocation()Optional<String>getName()Optional<Node>getParent()default <T> Tmap(T parent, BiFunction<Node.Feature,T,T> mapFeature, BiFunction<Node.Rule,T,T> mapRule, BiFunction<Node.Scenario,T,T> mapScenario, BiFunction<Node.ScenarioOutline,T,T> mapScenarioOutline, BiFunction<Node.Examples,T,T> mapExamples, BiFunction<Node.Example,T,T> mapExample)Recursively maps a node into another tree-like structure.
-
-
-
Method Detail
-
getLocation
Location getLocation()
-
map
default <T> T map(T parent, BiFunction<Node.Feature,T,T> mapFeature, BiFunction<Node.Rule,T,T> mapRule, BiFunction<Node.Scenario,T,T> mapScenario, BiFunction<Node.ScenarioOutline,T,T> mapScenarioOutline, BiFunction<Node.Examples,T,T> mapExamples, BiFunction<Node.Example,T,T> mapExample)Recursively maps a node into another tree-like structure.- Type Parameters:
T- the type of the target structure- Parameters:
parent- the parent node of the target structuremapFeature- a function that takes a feature and a parent node and returns a mapped featuremapRule- a function that takes a rule and a parent node and returns a mapped rulemapScenario- a function that takes a scenario and a parent node and returns a mapped scenariomapScenarioOutline- a function that takes a scenario outline and a parent node and returns a mapped scenario outlinemapExamples- a function that takes an examples and a parent node and returns a mapped examplesmapExample- a function that takes an example and a parent node and returns a mapped example- Returns:
- the mapped version of this instance
-
findPathTo
default Optional<List<Node>> findPathTo(Predicate<Node> predicate)
Finds a path down tree starting at this node to the first node that matches the predicate using depth first search.- Parameters:
predicate- to match the target node.- Returns:
- a path to the first node or an empty optional if none was found.
-
-