Interface JSONDelta.ChangeMap
- Enclosing interface:
- JSONDelta
The JSONDelta.inserted() method returns a
ChangeMap describing the parts of the second JSON value not found
in the first JSON value. Similarly, JSONDelta.removed()
returns a ChangeMap describing the parts of the first JSON value
not found in the second JSON value.
The map contains an entry for each change, as follows:
- The key is a JSON
Pointer syntax reference locating the change in the complete value.
Since a JSON value is a list of zero or more data items, the reference
always begins with an array index. For example, the first part is
identified by the JSON Pointer
/0. - The value is part of the complete value. It is returned as a
JSONthat can be parsed independently as a unit, orconverted to JSON.
Instances cannot be modified. Destructive methods such as
Map.put(Object, Object) throw
UnsupportedOperationException if called.
An IllegalArgumentException will be thrown if an invalid JSON
pointer expression is passed to Map.get(Object),
Map.containsKey(Object), descendants(String), or
intersection(String). This only occurs if the expression does
not start with / and is not empty.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondescendants(String pointer) Returns a view of the portion of this map whose keys are descendants ofpointer.intersection(String pointer) Returns a view of the portion of this map whose keys are descendants or parents ofpointer.Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Method Details
-
descendants
Returns a view of the portion of this map whose keys are descendants ofpointer. Ifpointeris contained in this map, it will be included in the result.- Throws:
IllegalArgumentException- if pointer is an invalid JSON Pointer expression
-
intersection
Returns a view of the portion of this map whose keys are descendants or parents ofpointer. Ifpointeris contained in this map, it will be included in the result.This method can be used to determine whether a structural delta affects a particular part of a JSON value. For example:
if (!structuralDelta.removed().intersection("/contact/address").isEmpty()) { // The structural delta removes elements that affect '/contact/address'. } if (!structuralDelta.inserted().intersection("/contact/address").isEmpty()) { // The structural delta inserts elements that affect '/contact/address'. }- Throws:
IllegalArgumentException- if pointer is an invalid JSON Pointer expression
-