@Test public void shouldRetrieveEmptyStreamForNonExistingChildren() { Stream<DocumentImplementation> children = document.children(KEY, DocumentImplementation::new); assertNotNull(children); assertEquals(0, children.count()); }
@Override public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) { Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null) .map(el -> (List<Map<String, Object>>) el).findAny(); return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty(); }
AbstractDocument implements Document { @Override public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) { Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null) .map(el -> (List<Map<String, Object>>) el).findAny(); return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty(); } }
AbstractDocument implements Document { @Override public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) { Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null) .map(el -> (List<Map<String, Object>>) el).findAny(); return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty(); } protected  AbstractDocument(Map<String, Object> properties); }
AbstractDocument implements Document { @Override public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) { Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null) .map(el -> (List<Map<String, Object>>) el).findAny(); return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty(); } protected  AbstractDocument(Map<String, Object> properties); @Override Void put(String key, Object value); @Override Object get(String key); @Override Stream<T> children(String key, Function<Map<String, Object>, T> constructor); @Override String toString(); }
AbstractDocument implements Document { @Override public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) { Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null) .map(el -> (List<Map<String, Object>>) el).findAny(); return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty(); } protected  AbstractDocument(Map<String, Object> properties); @Override Void put(String key, Object value); @Override Object get(String key); @Override Stream<T> children(String key, Function<Map<String, Object>, T> constructor); @Override String toString();  }