Package com.bazaarvoice.jolt.traversr
Class SimpleTraversal<DataType>
java.lang.Object
com.bazaarvoice.jolt.traversr.SimpleTraversal<DataType>
Utility class for use in custom Transforms.
Allows a programmer to just provide a single "human readable path"
that they will want to be able to execute against multiple trees of data.
Internally, parses the "human readable path" into a Traversr and a set of keys,
so that the user only needs to call get/set with their input tree.
Because the path is static, it is assumed that you will always be reading and writing
objects of the same type to the tree, therefore this class can take a generic
parameter "K" to reduce casting.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
traversr
-
keys
-
-
Constructor Details
-
SimpleTraversal
-
-
Method Details
-
newTraversal
Google Maps.newHashMap() trick to fill in generic type -
get
- Parameters:
tree
- tree of Map and List JSON structure to navigate- Returns:
- the object you wanted, or null if the object or any step along the path to it were not there
-
set
- Parameters:
tree
- tree of Map and List JSON structure to navigatedata
- JSON style data object you want to set- Returns:
- returns the data object if successfully set, otherwise null if there was a problem walking the path
-
remove
- Parameters:
tree
- tree of Map and List JSON structure to navigate- Returns:
- removes and returns the data object if it was able to successfully navigate to it and remove it.
-