JsonObject extends JsonValue { <R> Optional<R> maybeMapping(String key, Function<JsonValue, R> fn) { if (storage.containsKey(key)) { return Optional.of(fn.apply(childFor(key))); } else { return Optional.empty(); } } JsonObject(Map<String, Object> storage); @Override R requireObject(Function<JsonObject, R> mapper); Set<String> keySet(); Object get(String name);  }
@Test public void testMaybeWithFnMiss() { assertEquals(Optional.empty(), subject().maybeMapping("aaaa", ls -> 42)); }