26
26
* aggregating the {@link Status} instances and not deal with contextual details etc.
27
27
*
28
28
* @author Christian Dupuis
29
+ * @author Vedran Pavic
29
30
* @since 1.1.0
30
31
*/
31
32
public abstract class AbstractHealthAggregator implements HealthAggregator {
32
33
33
34
@ Override
34
35
public final Health aggregate (Map <String , Health > healths ) {
35
36
List <Status > statusCandidates = new ArrayList <Status >();
36
- Map <String , Object > details = new LinkedHashMap <String , Object >();
37
37
for (Map .Entry <String , Health > entry : healths .entrySet ()) {
38
- details .put (entry .getKey (), entry .getValue ());
39
38
statusCandidates .add (entry .getValue ().getStatus ());
40
39
}
41
- return new Health .Builder (aggregateStatus (statusCandidates ), details ).build ();
40
+ Status status = aggregateStatus (statusCandidates );
41
+ Map <String , Object > details = aggregateDetails (healths );
42
+ return new Health .Builder (status , details ).build ();
42
43
}
43
44
44
45
/**
@@ -49,4 +50,15 @@ public final Health aggregate(Map<String, Health> healths) {
49
50
*/
50
51
protected abstract Status aggregateStatus (List <Status > candidates );
51
52
53
+ /**
54
+ * Return the map of 'aggregate' details that should be used from the specified
55
+ * healths.
56
+ * @param healths the health instances to aggregate
57
+ * @return a map of details
58
+ * @since 1.3.1
59
+ */
60
+ protected Map <String , Object > aggregateDetails (Map <String , Health > healths ) {
61
+ return new LinkedHashMap <String , Object >(healths );
62
+ }
63
+
52
64
}
0 commit comments