Simplify construction of map of check results There isn't any need to convert the checks into an array of objects and then cast them back to their original types. Change-Id: If39d799f2fec670452e27eb7483a8d978c687c81
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java index 24eeca2..773b6c0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java +++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/check/GlobalHealthCheck.java
@@ -22,7 +22,6 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import com.googlesource.gerrit.plugins.healthcheck.HealthCheckConfig; -import java.util.Arrays; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -49,8 +48,7 @@ long ts = System.currentTimeMillis(); Map<String, Object> checkToResults = StreamSupport.stream(iterable.spliterator(), true) - .map(check -> Arrays.asList(check.name(), check.run())) - .collect(Collectors.toMap(k -> (String) k.get(0), v -> v.get(1))); + .collect(Collectors.toMap(HealthCheck::name, HealthCheck::run)); long elapsed = System.currentTimeMillis() - ts; StatusSummary globalStatus = new HealthCheck.StatusSummary( @@ -72,9 +70,6 @@ public static boolean hasAnyFailureOnResults(Map<String, Object> results) { return results.values().stream() - .anyMatch( - res -> - res instanceof StatusSummary - && ((StatusSummary) res).isFailure()); + .anyMatch(res -> res instanceof StatusSummary && ((StatusSummary) res).isFailure()); } }