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 Classes Modifier and Type Interface Description static class
TraversalStep.Operation
The three things you can do with a Traversal.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<DataType>
get(StepType tree, java.lang.String key)
Return the data for the key from the provided tree object.TraversalStep
getChild()
java.lang.Class<?>
getStepType()
Return the Class of the Generic T, so that it can be used in an "instanceof" style check.StepType
newContainer()
Create a new mutable Map or List, suitable for this PathElement to traverse.Optional<DataType>
overwriteSet(StepType tree, java.lang.String key, DataType data)
Insert the data into the tree, overwriting any data that is there.Optional<DataType>
remove(StepType tree, java.lang.String key)
Remove and return the data for the key from the provided tree object.Optional<DataType>
traverse(StepType tree, TraversalStep.Operation op, java.util.Iterator<java.lang.String> keys, DataType data)
The meat of the Traversal.
-
-
-
Method Detail
-
get
Optional<DataType> get(StepType tree, java.lang.String key)
Return the data for the key from the provided tree object.- Returns:
- data object if available, or null.
-
remove
Optional<DataType> remove(StepType tree, java.lang.String key)
Remove and return the data for the key from the provided tree object.- Returns:
- data object if available, or null.
-
overwriteSet
Optional<DataType> overwriteSet(StepType tree, java.lang.String key, DataType data)
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
java.lang.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, java.util.Iterator<java.lang.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
-
-