getValueAsJSONPatchIfAvailableByPosition method
Inquiry method that gets the difference between the new value and the previous one as a JSON Patch structure, provided that the Server has used the JSON Patch format to send this difference, as part of the "delta delivery" mechanism.
This, in turn, requires that:
- the Data Adapter has explicitly indicated JSON Patch as the privileged type of compression for this field;
- both the previous and new value are suitable for the JSON Patch computation (i.e. they are valid JSON representations);
- the item was subscribed to in MERGE or DISTINCT mode (note that, in case of two-level behavior, this holds for all fields related with second-level items, as these items are in MERGE mode);
- sending the JSON Patch difference has been evaluated by the Server as more efficient than sending the full new value.
When the above conditions are not met, the method just returns null; in this case, the new value can only be determined through [ItemUpdate.getValue]. For instance, this will always be needed to get the first value received.
Throws IllegalArgumentException if the specified field is not part of the Subscription.
fieldPosition
The 1-based position of the field within the "Field List" or "Field Schema".
Returns A JSON Patch structure representing the difference between the new value and the previous one, or null if the difference in JSON Patch format is not available for any reason.
Implementation
String? getValueAsJSONPatchIfAvailableByPosition(int fieldPosition) {
return _jsonFieldsByPosition[fieldPosition];
}