Package de.xima.fc.helper
Class JsonPathBuilder
java.lang.Object
de.xima.fc.helper.JsonPathBuilder
- All Implemented Interfaces:
org.apache.commons.lang3.builder.Builder<String>
public final class JsonPathBuilder
extends Object
implements org.apache.commons.lang3.builder.Builder<String>
Simple builder for a JSON path. Supports array elements and object properties.
- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
Constructor Summary
ConstructorsConstructorDescriptionJsonPathBuilder
(String root) Creates a new JSON path builder with the given root. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
enterArray
(int index) Adds an array element to the JSON path.enterObject
(String fieldName) Adds an object property to the JSON path.leave()
Leaves the most recently added array item or object property, i.e. drops it from the path.
-
Constructor Details
-
JsonPathBuilder
Creates a new JSON path builder with the given root.- Parameters:
root
- Root of the JSON path expression, usually$
.
-
-
Method Details
-
build
- Specified by:
build
in interfaceorg.apache.commons.lang3.builder.Builder<String>
- Returns:
- The current JSON path as a string.
-
enterArray
Adds an array element to the JSON path.- Parameters:
index
- Index of the array element- Returns:
- This builder for chaining method calls.
-
enterObject
Adds an object property to the JSON path.- Parameters:
fieldName
- Key of the object property.- Returns:
- This builder for chaining method calls.
-
leave
Leaves the most recently added array item or object property, i.e. drops it from the path.- Returns:
- This builder for chaining method calls.
-