Simplify some code

See gh-17832
This commit is contained in:
lijuny 2019-08-11 07:25:28 +08:00 committed by Stephane Nicoll
parent 835108e522
commit 844a8d8027
5 changed files with 5 additions and 9 deletions

View File

@ -131,8 +131,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
private Map<String, Object> getConfigurationPropertiesBeans(ApplicationContext context, private Map<String, Object> getConfigurationPropertiesBeans(ApplicationContext context,
ConfigurationBeanFactoryMetadata beanFactoryMetadata) { ConfigurationBeanFactoryMetadata beanFactoryMetadata) {
Map<String, Object> beans = new HashMap<>(); Map<String, Object> beans = new HashMap<>(context.getBeansWithAnnotation(ConfigurationProperties.class));
beans.putAll(context.getBeansWithAnnotation(ConfigurationProperties.class));
if (beanFactoryMetadata != null) { if (beanFactoryMetadata != null) {
beans.putAll(beanFactoryMetadata.getBeansWithFactoryAnnotation(ConfigurationProperties.class)); beans.putAll(beanFactoryMetadata.getBeansWithFactoryAnnotation(ConfigurationProperties.class));
} }

View File

@ -332,8 +332,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
} }
private Map<String, Object> getArguments(ServerWebExchange exchange, Map<String, String> body) { private Map<String, Object> getArguments(ServerWebExchange exchange, Map<String, String> body) {
Map<String, Object> arguments = new LinkedHashMap<>(); Map<String, Object> arguments = new LinkedHashMap<>(getTemplateVariables(exchange));
arguments.putAll(getTemplateVariables(exchange));
if (body != null) { if (body != null) {
arguments.putAll(body); arguments.putAll(body);
} }

View File

@ -310,8 +310,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
} }
private Map<String, Object> getArguments(HttpServletRequest request, Map<String, String> body) { private Map<String, Object> getArguments(HttpServletRequest request, Map<String, String> body) {
Map<String, Object> arguments = new LinkedHashMap<>(); Map<String, Object> arguments = new LinkedHashMap<>(getTemplateVariables(request));
arguments.putAll(getTemplateVariables(request));
String matchAllRemainingPathSegmentsVariable = this.operation.getRequestPredicate() String matchAllRemainingPathSegmentsVariable = this.operation.getRequestPredicate()
.getMatchAllRemainingPathSegmentsVariable(); .getMatchAllRemainingPathSegmentsVariable();
if (matchAllRemainingPathSegmentsVariable != null) { if (matchAllRemainingPathSegmentsVariable != null) {

View File

@ -40,8 +40,7 @@ public final class Info {
private final Map<String, Object> details; private final Map<String, Object> details;
private Info(Builder builder) { private Info(Builder builder) {
Map<String, Object> content = new LinkedHashMap<>(); Map<String, Object> content = new LinkedHashMap<>(builder.content);
content.putAll(builder.content);
this.details = Collections.unmodifiableMap(content); this.details = Collections.unmodifiableMap(content);
} }

View File

@ -126,7 +126,7 @@ class StartupInfoLogger {
} }
private void appendPid(StringBuilder message) { private void appendPid(StringBuilder message) {
append(message, "with PID ", () -> new ApplicationPid()); append(message, "with PID ", ApplicationPid::new);
} }
private void appendContext(StringBuilder message) { private void appendContext(StringBuilder message) {