Skip to content
Permalink
Browse files
Retain order in TaskReport. (#12005)
  • Loading branch information
gianm committed Mar 4, 2022
1 parent 61e1ffc commit ada3ae08dfc432f34e4ef1ec87f9800c91ba2c54
Showing 1 changed file with 6 additions and 2 deletions.
@@ -22,7 +22,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
@@ -44,9 +44,13 @@
*/
Object getPayload();

/**
* Returns an order-preserving map that is suitable for passing into {@link TaskReportFileWriter#write}.
*/
static Map<String, TaskReport> buildTaskReports(TaskReport... taskReports)
{
Map<String, TaskReport> taskReportMap = new HashMap<>();
// Use LinkedHashMap to preserve order of the reports.
Map<String, TaskReport> taskReportMap = new LinkedHashMap<>();
for (TaskReport taskReport : taskReports) {
taskReportMap.put(taskReport.getReportKey(), taskReport);
}

0 comments on commit ada3ae0

Please sign in to comment.