diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java index ad4239a10b4..4e8f9fc6c00 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java @@ -16,6 +16,8 @@ package org.springframework.boot.actuate.endpoint; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -66,27 +68,36 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint { @JsonInclude(Include.NON_EMPTY) public static class Report { - private MultiValueMap positiveMatches; + private final MultiValueMap positiveMatches; - private MultiValueMap negativeMatches; + private final Map negativeMatches; - private List exclusions; + private final List exclusions; - private Report parent; + private final Report parent; public Report(ConditionEvaluationReport report) { this.positiveMatches = new LinkedMultiValueMap(); - this.negativeMatches = new LinkedMultiValueMap(); + this.negativeMatches = new LinkedHashMap(); this.exclusions = report.getExclusions(); for (Map.Entry entry : report .getConditionAndOutcomesBySource().entrySet()) { - add(entry.getValue().isFullMatch() ? this.positiveMatches - : this.negativeMatches, entry.getKey(), entry.getValue()); + if (entry.getValue().isFullMatch()) { + add(this.positiveMatches, entry.getKey(), entry.getValue()); + } + else { + add(this.negativeMatches, entry.getKey(), entry.getValue()); + } + } + this.parent = report.getParent() != null ? new Report(report.getParent()) + : null; + } - } - if (report.getParent() != null) { - this.parent = new Report(report.getParent()); - } + private void add(Map map, String source, + ConditionAndOutcomes conditionAndOutcomes) { + String name = ClassUtils.getShortName(source); + + map.put(name, new MessageAndConditions(conditionAndOutcomes)); } private void add(MultiValueMap map, String source, @@ -101,7 +112,7 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint { return this.positiveMatches; } - public Map> getNegativeMatches() { + public Map getNegativeMatches() { return this.negativeMatches; } @@ -115,6 +126,34 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint { } + /** + * Adapts {@link ConditionAndOutcomes} to a JSON friendly structure. + */ + @JsonPropertyOrder({ "notMatched", "matched" }) + public static class MessageAndConditions { + + private final List notMatched = new ArrayList(); + + private final List matched = new ArrayList(); + + public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) { + for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) { + List target = conditionAndOutcome.getOutcome() + .isMatch() ? this.matched : this.notMatched; + target.add(new MessageAndCondition(conditionAndOutcome)); + } + } + + public List getNotMatched() { + return this.notMatched; + } + + public List getMatched() { + return this.matched; + } + + } + /** * Adapts {@link ConditionAndOutcome} to a JSON friendly structure. */ @@ -146,4 +185,5 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint { } } + }