T - The type of Object worked on.U - The type of Object returned.public final class JsonNodeSelector<T,U>
extends java.lang.Object
JsonNodeSelector extract values from Objects of a specified type.
For example, given a JsonNode representing {"Fee":{"fi":"fo"}},
anObjectNodeWithField("Fee")
.withChild(anObjectNodeWithField("fi"))
.withChild(aStringNode())
.getValue(jsonNode)
will return the String "fo".JsonNodeSelectors| Modifier and Type | Method and Description |
|---|---|
U |
getValue(T argument)
Extracts a value from the give
JsonNode. |
boolean |
matches(T argument)
Determines whether this
JsonNodeSelector can extract a value from the given JsonNode. |
java.lang.String |
toString() |
<V> JsonNodeSelector<T,V> |
with(JsonNodeSelector<U,V> childJsonNodeSelector)
Constructs a JsonNodeSelector consisting of this chained with the given
JsonNodeSelector. |
public boolean matches(T argument)
JsonNodeSelector can extract a value from the given JsonNode.argument - the JsonNode to test.JsonNode, false otherwise.public U getValue(T argument)
JsonNode.argument - the JsonNode to extract a value from.java.lang.IllegalArgumentException - if calling matches with the given JsonNode would return false, indicating no value can be extracted from it.public <V> JsonNodeSelector<T,V> with(JsonNodeSelector<U,V> childJsonNodeSelector)
Constructs a JsonNodeSelector consisting of this chained with the given JsonNodeSelector.
For example, if we have a JsonNodeSelector for the first element of an array, and another that
selects the second element of an array, and we chain them together in that order, we will get a selector that
works on nested arrays, selecting the second element from an array stored in the first element of a parent
array.
V - the type the chained JsonNodeSelector will return.childJsonNodeSelector - the JsonNodeSelector to chain onto this.JsonNodeSelector representing this, and the given selector applied in sequence.public java.lang.String toString()
toString in class java.lang.Object