Merge pull request #19291 from dreis2211

* pr/19291:
  Simplify some Stream API usages

Closes gh-19291
pull/19327/head
Stephane Nicoll 5 years ago
commit 9136f54a5c

@ -43,7 +43,7 @@ abstract class NamedContributorsMapAdapter<V, C> implements NamedContributors<C>
NamedContributorsMapAdapter(Map<String, V> map, Function<V, ? extends C> valueAdapter) { NamedContributorsMapAdapter(Map<String, V> map, Function<V, ? extends C> valueAdapter) {
Assert.notNull(map, "Map must not be null"); Assert.notNull(map, "Map must not be null");
Assert.notNull(valueAdapter, "ValueAdapter must not be null"); Assert.notNull(valueAdapter, "ValueAdapter must not be null");
map.keySet().stream().forEach((key) -> Assert.notNull(key, "Map must not contain null keys")); map.keySet().forEach((key) -> Assert.notNull(key, "Map must not contain null keys"));
map.values().stream().map(valueAdapter) map.values().stream().map(valueAdapter)
.forEach((value) -> Assert.notNull(value, "Map must not contain null values")); .forEach((value) -> Assert.notNull(value, "Map must not contain null values"));
this.map = Collections.unmodifiableMap(new LinkedHashMap<>(map)); this.map = Collections.unmodifiableMap(new LinkedHashMap<>(map));

@ -69,7 +69,7 @@ public class SimpleStatusAggregator implements StatusAggregator {
@Override @Override
public Status getAggregateStatus(Set<Status> statuses) { public Status getAggregateStatus(Set<Status> statuses) {
return statuses.stream().filter(this::contains).sorted(this.comparator).findFirst().orElse(Status.UNKNOWN); return statuses.stream().filter(this::contains).min(this.comparator).orElse(Status.UNKNOWN);
} }
private boolean contains(Status status) { private boolean contains(Status status) {

@ -96,7 +96,7 @@ class EmbeddedMongoAutoConfigurationTests {
features.add(Feature.ONLY_WINDOWS_2008_SERVER); features.add(Feature.ONLY_WINDOWS_2008_SERVER);
} }
load("spring.mongodb.embedded.features=" load("spring.mongodb.embedded.features="
+ String.join(", ", features.stream().map(Feature::name).collect(Collectors.toList()))); + features.stream().map(Feature::name).collect(Collectors.joining(", ")));
assertThat(this.context.getBean(EmbeddedMongoProperties.class).getFeatures()) assertThat(this.context.getBean(EmbeddedMongoProperties.class).getFeatures())
.containsExactlyElementsOf(features); .containsExactlyElementsOf(features);
} }

Loading…
Cancel
Save