Interface ConfigurationVisitor<S,T,E extends Exception>
- Type Parameters:
S
- A state object that will be used for one visitT
- The terminal value, that can be returned at the end of the visitE
- exception type that may be thrown
- All Known Subinterfaces:
ConfigurationVisitor.Safe<S,T>
,ConfigurationVisitor.Stateless<E>
public interface ConfigurationVisitor<S,T,E extends Exception>
Instances of stateful implementations may be reusable by taking advantage of the state object. During each visitation, a visitor will experience the node tree as a sequence of events, described by the following pseudo-grammar:
mappingNode: enterMappingNode node* exitMappingNode listNode: enterListNode node* exitListNode node: enterNode (mappingNode | listNode | enterScalarNode) visit: newState? beginVisit node* endVisit
If the starting node has no value, no node events will be received. Otherwise, the first event received will be for the starting node itself, and will continue from there.
The children to visit for list and mapping nodes will only be collected after both the enterNode
and
enter(List|Mapping)Node
methods have been executed for the node, and changes to the node values may be made to
control which nodes will be visited.
Any exceptions thrown within the visitor will result in the visitation ending immediately and the exception being rethrown within the visit method
There are a few specializations of the visitor interface available: ConfigurationVisitor.Stateless
carries no state and can act as
a functional interface type, and ConfigurationVisitor.Safe
which throws no checked exceptions and therefore can be visited without
having to handle any exceptions.
- See Also:
to execute this configuration visitation
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ConfigurationVisitor.Safe<S,T>
A subinterface for visitors that do not throw any checked exceptions during their executionstatic interface
ConfigurationVisitor.Stateless<E extends Exception>
Stateless specialization of visitors, where both the state and terminal type are Void -
Method Summary
Modifier and Type Method Description void
beginVisit(ConfigurationNode node, S state)
Called at the beginning of the visit with a state object created.T
endVisit(S state)
Called after every node has been visited, to allow for cleanup and validationvoid
enterListNode(ConfigurationNode node, S state)
Called afterenterNode(ConfigurationNode, Object)
for list nodesvoid
enterMappingNode(ConfigurationNode node, S state)
Called afterenterNode(ConfigurationNode, Object)
for mapping nodesvoid
enterNode(ConfigurationNode node, S state)
Called once per node, for every nodevoid
enterScalarNode(ConfigurationNode node, S state)
Called afterenterNode(ConfigurationNode, Object)
for scalar nodesvoid
exitListNode(ConfigurationNode node, S state)
Called for a list node after the node and any of its children have been visitedvoid
exitMappingNode(ConfigurationNode node, S state)
Called for a list node after the node and any of its children have been visitedS
newState()
Called to provide a state object if a visit is initiated without one already existing
-
Method Details
-
newState
Called to provide a state object if a visit is initiated without one already existing- Returns:
- A new state object to be passed through the rest of this visit
- Throws:
E
- when thrown by implementation
-
beginVisit
Called at the beginning of the visit with a state object created.- Parameters:
node
- the root nodestate
- the state- Throws:
E
- when thrown by implementation
-
enterNode
Called once per node, for every node- Parameters:
node
- The current nodestate
- provided state- Throws:
E
- when thrown by implementation
-
enterMappingNode
Called afterenterNode(ConfigurationNode, Object)
for mapping nodes- Parameters:
node
- current nodestate
- provided state- Throws:
E
- when thrown by implementation
-
enterListNode
Called afterenterNode(ConfigurationNode, Object)
for list nodes- Parameters:
node
- current nodestate
- provided state- Throws:
E
- when thrown by implementation
-
enterScalarNode
Called afterenterNode(ConfigurationNode, Object)
for scalar nodes- Parameters:
node
- current nodestate
- provided state- Throws:
E
- when thrown by implementation
-
exitMappingNode
Called for a list node after the node and any of its children have been visited- Parameters:
node
- The node that has been visitedstate
- provided state- Throws:
E
- when thrown by implementation
-
exitListNode
Called for a list node after the node and any of its children have been visited- Parameters:
node
- The node that has been visitedstate
- provided state- Throws:
E
- when thrown by implementation
-
endVisit
Called after every node has been visited, to allow for cleanup and validation- Parameters:
state
- provided state- Returns:
- a terminal value
- Throws:
E
- when thrown by implementation
-