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());
}