Interface: MapDiff Stay organized with collections Save and categorize content based on your preferences.
rules. MapDiff
MapDiff type.
The MapDiff type represents the result of comparing tworules.Map objects.
There is no MapDiff literal for use in creating diffs. MapDiff objects are returned by calls to therules.Map#diff function.
The MapDiff functions described below are called by chaining withrules.Map#diff. All MapDiff functions returnrules.Set objects listing keys compared between Map objects.
// Compare two Map objects and return whether the key "a" has been// affected; that is, key "a" was added or removed, or its value was updated.request.resource.data.diff(resource.data).affectedKeys().hasOnly(["a"]);
Methods
addedKeys
addedKeys() returns rules.Set
Returns arules.Set, which lists any keys that the Map callingdiff() contains that the Map passed todiff() does not.
Example
{"a":1}.diff({}).addedKeys() == ["a"].toSet()affectedKeys
affectedKeys() returns rules.Set
Returns arules.Set, which lists any keys that have been added to, removed from or modified from the Map callingdiff() compared to the Map passed todiff(). This function returns the set equivalent to the combined results ofMapDiff.addedKeys(),MapDiff.removedKeys() andMapDiff.changedKeys().
({"a":0, "c":0, "u":0}).diff({"r":0, "c":1, "u": 0}).affectedKeys() == ["a", "r", "c"].toSet()- Returns
non-nullrules.Set,a list of keys added to, removed from or changed from therules.Map passed to theMap.diff()function.
changedKeys
changedKeys() returns rules.Set
Returns arules.Set, which lists any keys that appear in both the Map callingdiff() and the Map passed todiff(), but whose values are not equal.
- Returns
non-nullrules.Set, a list of keys that appear in bothrules.Maps but whose values are not equal.
Example
{"a":0}.diff({"a":1, "b":4}).changedKeys() == ["a"].toSet()removedKeys
removedKeys() returns rules.Set
Returns arules.Set, which lists any keys that the Map callingdiff() does not contain compared to the Map passed todiff().
- Returns
non-nullrules.Set, a list of keys removed from therules.Map passed to theMap.diff()function.
Example
{}.diff({"a":1}).removedKeys() == ["a"].toSet()unchangedKeys
unchangedKeys() returns rules.Set
Returns arules.Set, which lists any keys that appear in both the Map callingdiff() and the Map passed todiff(), and whose values are equal.
Example
{"a": 0}.diff({"a":0}).unchangedKeys() == ["a"].toSet()Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-03-04 UTC.