Interface TraversalStep<StepType,DataType>
- All Known Implementing Classes:
ArrayTraversalStep
,AutoExpandArrayTraversalStep
,BaseTraversalStep
,MapTraversalStep
public interface TraversalStep<StepType,DataType>
A step in a JSON tree traversal.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
The three things you can do with a Traversal. -
Method Summary
Modifier and TypeMethodDescriptionReturn the data for the key from the provided tree object.getChild()
Class
<?> Return the Class of the Generic T, so that it can be used in an "instanceof" style check.Create a new mutable Map or List, suitable for this PathElement to traverse.overwriteSet
(StepType tree, String key, DataType data) Insert the data into the tree, overwriting any data that is there.Remove and return the data for the key from the provided tree object.The meat of the Traversal.
-
Method Details
-
get
Return the data for the key from the provided tree object.- Returns:
- data object if available, or null.
-
remove
Remove and return the data for the key from the provided tree object.- Returns:
- data object if available, or null.
-
overwriteSet
Insert the data into the tree, overwriting any data that is there.- Returns:
- returns the data object if successful or null if it could not
-
getChild
TraversalStep getChild()- Returns:
- the child Traversal or null if this Traversal has no child
-
newContainer
StepType newContainer()Create a new mutable Map or List, suitable for this PathElement to traverse.- Returns:
- new List or Map, depending on the type of the Traversal
-
getStepType
Class<?> getStepType()Return the Class of the Generic T, so that it can be used in an "instanceof" style check.- Returns:
- Class that matches Generic parameter T
-
traverse
Optional<DataType> traverse(StepType tree, TraversalStep.Operation op, Iterator<String> keys, DataType data) The meat of the Traversal. Pull a key from the iterator, use it to make the traversal, and then call traverse on your child Traversal.- Parameters:
tree
- tree of data to walkop
- the Operation to perform is this is the last node of the Traversalkeys
- keys to usedata
- the data to place if the operation is SET- Returns:
- if SET, null for fail or the "data" object for ok. if GET, PANTS
-