From 6d46c473d41c6c47e6b8bd8c676d925e544bd378 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Fri, 5 Jul 2024 12:43:13 -0400 Subject: More cleanup --- .../net/wotonomy/foundation/NSKeyValueCodingAdditions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSKeyValueCodingAdditions.java') 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 valuesForKeys(List aKeyList); + default NSDictionary valuesForKeys(List aKeyList) { + NSDictionary 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 aMap); + default void takeValuesFromDictionary(Map aMap) { + aMap.forEach((key, val) -> takeValueForKey(val, key)); + } /** * Static utility methods that call the appropriate method if the object -- cgit v1.2.3