Skip to content

Commit

Permalink
clean code (iluwatar#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimAlii authored and iluwatar committed Sep 7, 2019
1 parent c653edf commit 8c865e6
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,16 @@ public Object get(String key) {

@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)
Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(Objects::nonNull)
.map(el -> (List<Map<String, Object>>) el).findAny();
return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty();
return any.map(maps -> maps.stream().map(constructor)).orElseGet(Stream::empty);
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName()).append("[");
properties.entrySet()
.forEach(e -> builder.append("[").append(e.getKey()).append(" : ").append(e.getValue()).append("]"));
properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value).append("]"));
builder.append("]");
return builder.toString();
}
Expand Down

0 comments on commit 8c865e6

Please sign in to comment.