X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Futil%2FLangUtils.java;h=2f99bb3e0d735bb75a99704ce9ffbee2847b560c;hb=d289fa62f9dadd0a5bd49ab5e3d499e87152525d;hp=779adb01eb4a204dd2dc07d27bee06be386d6083;hpb=dffc0df8766937ad0863d389883cba2ebac835d6;p=lgpl%2Fargeo-commons.git
diff --git a/org.argeo.util/src/org/argeo/util/LangUtils.java b/org.argeo.util/src/org/argeo/util/LangUtils.java
index 779adb01e..2f99bb3e0 100644
--- a/org.argeo.util/src/org/argeo/util/LangUtils.java
+++ b/org.argeo.util/src/org/argeo/util/LangUtils.java
@@ -71,6 +71,29 @@ public class LangUtils {
return res;
}
+ /**
+ * Get a string property from this map, expecting to find it, or
+ * null
if not found.
+ */
+ public static String get(Map map, String key) {
+ Object res = map.get(key);
+ if (res == null)
+ return null;
+ return res.toString();
+ }
+
+ /**
+ * Get a string property from this map, expecting to find it.
+ *
+ * @throws IllegalArgumentException if the key was not found
+ */
+ public static String getNotNull(Map map, String key) {
+ Object res = map.get(key);
+ if (res == null)
+ throw new IllegalArgumentException("Map " + map + " should contain key " + key);
+ return res.toString();
+ }
+
/**
* Wraps the keys of the provided {@link Dictionary} as an {@link Iterable}.
*/