Separate conditions that did and did not match in auto-config endpoint
Closes gh-7122
This commit is contained in:
parent
c06dc33bf6
commit
9b6fa1e8d7
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.endpoint;
|
package org.springframework.boot.actuate.endpoint;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -66,27 +68,36 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||||
@JsonInclude(Include.NON_EMPTY)
|
@JsonInclude(Include.NON_EMPTY)
|
||||||
public static class Report {
|
public static class Report {
|
||||||
|
|
||||||
private MultiValueMap<String, MessageAndCondition> positiveMatches;
|
private final MultiValueMap<String, MessageAndCondition> positiveMatches;
|
||||||
|
|
||||||
private MultiValueMap<String, MessageAndCondition> negativeMatches;
|
private final Map<String, MessageAndConditions> negativeMatches;
|
||||||
|
|
||||||
private List<String> exclusions;
|
private final List<String> exclusions;
|
||||||
|
|
||||||
private Report parent;
|
private final Report parent;
|
||||||
|
|
||||||
public Report(ConditionEvaluationReport report) {
|
public Report(ConditionEvaluationReport report) {
|
||||||
this.positiveMatches = new LinkedMultiValueMap<String, MessageAndCondition>();
|
this.positiveMatches = new LinkedMultiValueMap<String, MessageAndCondition>();
|
||||||
this.negativeMatches = new LinkedMultiValueMap<String, MessageAndCondition>();
|
this.negativeMatches = new LinkedHashMap<String, MessageAndConditions>();
|
||||||
this.exclusions = report.getExclusions();
|
this.exclusions = report.getExclusions();
|
||||||
for (Map.Entry<String, ConditionAndOutcomes> entry : report
|
for (Map.Entry<String, ConditionAndOutcomes> entry : report
|
||||||
.getConditionAndOutcomesBySource().entrySet()) {
|
.getConditionAndOutcomesBySource().entrySet()) {
|
||||||
add(entry.getValue().isFullMatch() ? this.positiveMatches
|
if (entry.getValue().isFullMatch()) {
|
||||||
: this.negativeMatches, entry.getKey(), entry.getValue());
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
private void add(Map<String, MessageAndConditions> map, String source,
|
||||||
if (report.getParent() != null) {
|
ConditionAndOutcomes conditionAndOutcomes) {
|
||||||
this.parent = new Report(report.getParent());
|
String name = ClassUtils.getShortName(source);
|
||||||
}
|
|
||||||
|
map.put(name, new MessageAndConditions(conditionAndOutcomes));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(MultiValueMap<String, MessageAndCondition> map, String source,
|
private void add(MultiValueMap<String, MessageAndCondition> map, String source,
|
||||||
|
|
@ -101,7 +112,7 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||||
return this.positiveMatches;
|
return this.positiveMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<MessageAndCondition>> getNegativeMatches() {
|
public Map<String, MessageAndConditions> getNegativeMatches() {
|
||||||
return this.negativeMatches;
|
return this.negativeMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,6 +126,34 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapts {@link ConditionAndOutcomes} to a JSON friendly structure.
|
||||||
|
*/
|
||||||
|
@JsonPropertyOrder({ "notMatched", "matched" })
|
||||||
|
public static class MessageAndConditions {
|
||||||
|
|
||||||
|
private final List<MessageAndCondition> notMatched = new ArrayList<MessageAndCondition>();
|
||||||
|
|
||||||
|
private final List<MessageAndCondition> matched = new ArrayList<MessageAndCondition>();
|
||||||
|
|
||||||
|
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
|
||||||
|
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
||||||
|
List<MessageAndCondition> target = conditionAndOutcome.getOutcome()
|
||||||
|
.isMatch() ? this.matched : this.notMatched;
|
||||||
|
target.add(new MessageAndCondition(conditionAndOutcome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageAndCondition> getNotMatched() {
|
||||||
|
return this.notMatched;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageAndCondition> getMatched() {
|
||||||
|
return this.matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapts {@link ConditionAndOutcome} to a JSON friendly structure.
|
* Adapts {@link ConditionAndOutcome} to a JSON friendly structure.
|
||||||
*/
|
*/
|
||||||
|
|
@ -146,4 +185,5 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue