Polish some Map operations

Closes gh-15103
This commit is contained in:
dreis2211 2018-11-05 20:11:31 +01:00 committed by Stephane Nicoll
parent 804f647a34
commit 3e95af2c85
5 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -102,9 +102,9 @@ public class HealthStatusHttpMapper {
public int mapStatus(Status status) {
String code = getUniformValue(status.getCode());
if (code != null) {
return this.statusMapping.keySet().stream()
.filter((key) -> code.equals(getUniformValue(key)))
.map(this.statusMapping::get).findFirst()
return this.statusMapping.entrySet().stream()
.filter((entry) -> code.equals(getUniformValue(entry.getKey())))
.map(Map.Entry::getValue).findFirst()
.orElse(WebEndpointResponse.STATUS_OK);
}
return WebEndpointResponse.STATUS_OK;

View File

@ -79,8 +79,7 @@ public class SessionsEndpoint {
private final List<SessionDescriptor> sessions;
public SessionsReport(Map<String, ? extends Session> sessions) {
this.sessions = sessions.entrySet().stream()
.map((s) -> new SessionDescriptor(s.getValue()))
this.sessions = sessions.values().stream().map(SessionDescriptor::new)
.collect(Collectors.toList());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -85,7 +85,7 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans.entrySet()).isEmpty();
assertThat(beans).isEmpty();
}
@Test(expected = IllegalArgumentException.class)

View File

@ -68,8 +68,8 @@ class JavaBeanBinder implements BeanBinder {
private <T> boolean bind(BeanPropertyBinder propertyBinder, Bean<T> bean,
BeanSupplier<T> beanSupplier) {
boolean bound = false;
for (Map.Entry<String, BeanProperty> entry : bean.getProperties().entrySet()) {
bound |= bind(beanSupplier, propertyBinder, entry.getValue());
for (BeanProperty beanProperty : bean.getProperties().values()) {
bound |= bind(beanSupplier, propertyBinder, beanProperty);
}
return bound;
}

View File

@ -620,7 +620,7 @@ public class MapBinderTests {
.withExistingValue(Collections.singletonMap("a", "b")))
.get();
assertThat(result).hasSize(3);
assertThat(result.entrySet()).containsExactly(entry("a", "b"), entry("c", "d"),
assertThat(result).containsExactly(entry("a", "b"), entry("c", "d"),
entry("e", "f"));
}