diff options
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java index 72c9fc8..a93fff9 100644 --- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java @@ -49,13 +49,23 @@ public interface NSKeyValueCodingAdditions extends NSKeyValueCoding { * Returns a Map of the specified keys to their values, each of which might be * obtained by calling valueForKey. */ - NSDictionary<String, Object> valuesForKeys(List<String> aKeyList); + default NSDictionary<String, Object> valuesForKeys(List<String> aKeyList) { + NSDictionary<String, Object> ret = new NSMutableDictionary<>(); + + for (String key : aKeyList) { + ret.put(key, valueForKey(key)); + } + + return ret; + } /** * Takes the keys from the specified map as properties and applies the * corresponding values, each of which might be set by calling takeValueForKey. */ - void takeValuesFromDictionary(Map<String, Object> aMap); + default void takeValuesFromDictionary(Map<String, Object> aMap) { + aMap.forEach((key, val) -> takeValueForKey(val, key)); + } /** * Static utility methods that call the appropriate method if the object |
