Commit 59552319 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #15103 from dreis2211

* pr/15103:
  Polish some Map operations
parents 804f647a 3e95af2c
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -102,9 +102,9 @@ public class HealthStatusHttpMapper { ...@@ -102,9 +102,9 @@ public class HealthStatusHttpMapper {
public int mapStatus(Status status) { public int mapStatus(Status status) {
String code = getUniformValue(status.getCode()); String code = getUniformValue(status.getCode());
if (code != null) { if (code != null) {
return this.statusMapping.keySet().stream() return this.statusMapping.entrySet().stream()
.filter((key) -> code.equals(getUniformValue(key))) .filter((entry) -> code.equals(getUniformValue(entry.getKey())))
.map(this.statusMapping::get).findFirst() .map(Map.Entry::getValue).findFirst()
.orElse(WebEndpointResponse.STATUS_OK); .orElse(WebEndpointResponse.STATUS_OK);
} }
return WebEndpointResponse.STATUS_OK; return WebEndpointResponse.STATUS_OK;
......
...@@ -79,8 +79,7 @@ public class SessionsEndpoint { ...@@ -79,8 +79,7 @@ public class SessionsEndpoint {
private final List<SessionDescriptor> sessions; private final List<SessionDescriptor> sessions;
public SessionsReport(Map<String, ? extends Session> sessions) { public SessionsReport(Map<String, ? extends Session> sessions) {
this.sessions = sessions.entrySet().stream() this.sessions = sessions.values().stream().map(SessionDescriptor::new)
.map((s) -> new SessionDescriptor(s.getValue()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -85,7 +85,7 @@ public class PersistenceExceptionTranslationAutoConfigurationTests { ...@@ -85,7 +85,7 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
this.context.refresh(); this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class); .getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
assertThat(beans.entrySet()).isEmpty(); assertThat(beans).isEmpty();
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
......
...@@ -68,8 +68,8 @@ class JavaBeanBinder implements BeanBinder { ...@@ -68,8 +68,8 @@ class JavaBeanBinder implements BeanBinder {
private <T> boolean bind(BeanPropertyBinder propertyBinder, Bean<T> bean, private <T> boolean bind(BeanPropertyBinder propertyBinder, Bean<T> bean,
BeanSupplier<T> beanSupplier) { BeanSupplier<T> beanSupplier) {
boolean bound = false; boolean bound = false;
for (Map.Entry<String, BeanProperty> entry : bean.getProperties().entrySet()) { for (BeanProperty beanProperty : bean.getProperties().values()) {
bound |= bind(beanSupplier, propertyBinder, entry.getValue()); bound |= bind(beanSupplier, propertyBinder, beanProperty);
} }
return bound; return bound;
} }
......
...@@ -620,7 +620,7 @@ public class MapBinderTests { ...@@ -620,7 +620,7 @@ public class MapBinderTests {
.withExistingValue(Collections.singletonMap("a", "b"))) .withExistingValue(Collections.singletonMap("a", "b")))
.get(); .get();
assertThat(result).hasSize(3); 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")); entry("e", "f"));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment