|
18 | 18 | import java.util.HashMap; |
19 | 19 | import java.util.List; |
20 | 20 | import java.util.Map; |
| 21 | +import java.util.Objects; |
21 | 22 | import java.util.Set; |
22 | 23 | import java.util.TreeMap; |
23 | 24 |
|
24 | 25 | import static java.util.Comparator.comparing; |
| 26 | +import static java.util.Comparator.comparingInt; |
25 | 27 | import static java.util.stream.Collectors.groupingBy; |
26 | 28 | import static java.util.stream.Collectors.toList; |
27 | 29 |
|
@@ -66,12 +68,23 @@ static void update(File templateFile, File outputFile, QualifiedVersion version, |
66 | 68 | static String generateFile(String template, QualifiedVersion version, Set<ChangelogEntry> changelogs) throws IOException { |
67 | 69 | final var changelogsByTypeByArea = buildChangelogBreakdown(changelogs); |
68 | 70 |
|
| 71 | + final Map<Boolean, List<ChangelogEntry.Highlight>> groupedHighlights = changelogs.stream() |
| 72 | + .map(ChangelogEntry::getHighlight) |
| 73 | + .filter(Objects::nonNull) |
| 74 | + .sorted(comparingInt(ChangelogEntry.Highlight::getPr)) |
| 75 | + .collect(groupingBy(ChangelogEntry.Highlight::isNotable, toList())); |
| 76 | + |
| 77 | + final List<ChangelogEntry.Highlight> notableHighlights = groupedHighlights.getOrDefault(true, List.of()); |
| 78 | + final List<ChangelogEntry.Highlight> nonNotableHighlights = groupedHighlights.getOrDefault(false, List.of()); |
| 79 | + |
69 | 80 | final Map<String, Object> bindings = new HashMap<>(); |
70 | 81 | bindings.put("version", version); |
71 | 82 | bindings.put("changelogsByTypeByArea", changelogsByTypeByArea); |
72 | 83 | bindings.put("TYPE_LABELS", TYPE_LABELS); |
73 | 84 | bindings.put("unqualifiedVersion", version.withoutQualifier()); |
74 | 85 | bindings.put("versionWithoutSeparator", version.withoutQualifier().toString().replaceAll("\\.", "")); |
| 86 | + bindings.put("notableHighlights", notableHighlights); |
| 87 | + bindings.put("nonNotableHighlights", nonNotableHighlights); |
75 | 88 |
|
76 | 89 | return TemplateUtils.render(template, bindings); |
77 | 90 | } |
|
0 commit comments