sS getStringOpt(Map map, O key) { ret map == null ? null : optCast(S, map.get(key)); } sS getStringOpt(L l, int idx) { ret optCast(S, get(l, idx)); } sS getStringOpt(O o, O key) { if (o instanceof Map) ret getStringOpt((Map) o, key); if (key instanceof S) ret optCast(S, getOpt(o, (S) key)); throw fail("Not a string key: " + getClassName(key)); } sS mapMethodLike getStringOpt(S key, O o) { ret getStringOpt(o, (O) key); }