|
16 | 16 |
|
17 | 17 | import java.io.PrintWriter; |
18 | 18 | import java.util.List; |
| 19 | +import java.util.Map; |
19 | 20 | import java.util.Set; |
20 | 21 | import java.util.TreeMap; |
21 | 22 |
|
@@ -52,22 +53,27 @@ public void printDeclarationInfo(PrintWriter out, Set<Status> statuses) { |
52 | 53 | protected void printDeclarationSection(Set<Status> statuses, Status status, List<Declaration> declarations, |
53 | 54 | PrintWriter out) { |
54 | 55 | printDeclarationSectionHeader(statuses, status, declarations, out); |
55 | | - declarations.stream() // |
56 | | - .collect(groupingBy(Declaration::moduleName, TreeMap::new, toList())) // |
57 | | - .forEach((moduleName, moduleDeclarations) -> { |
58 | | - out.println(h4("Module " + moduleName)); |
59 | | - out.println(); |
60 | | - moduleDeclarations.stream() // |
61 | | - .collect(groupingBy(Declaration::packageName, TreeMap::new, toList())) // |
62 | | - .forEach((packageName, packageDeclarations) -> { |
63 | | - out.println(h5("Package " + packageName)); |
64 | | - out.println(); |
65 | | - printDeclarationTableHeader(out); |
66 | | - packageDeclarations.forEach(it -> printDeclarationTableRow(it, out)); |
67 | | - printDeclarationTableFooter(out); |
68 | | - out.println(); |
69 | | - }); |
70 | | - }); |
| 56 | + Map<String, List<Declaration>> declarationsByModule = declarations.stream() // |
| 57 | + .collect(groupingBy(Declaration::moduleName, TreeMap::new, toList())); |
| 58 | + if (declarationsByModule.isEmpty()) { |
| 59 | + out.println(paragraph("NOTE: There are currently no APIs annotated with %s.".formatted( |
| 60 | + code("@API(status = %s)".formatted(status.name()))))); |
| 61 | + return; |
| 62 | + } |
| 63 | + declarationsByModule.forEach((moduleName, moduleDeclarations) -> { |
| 64 | + out.println(h4("Module " + moduleName)); |
| 65 | + out.println(); |
| 66 | + moduleDeclarations.stream() // |
| 67 | + .collect(groupingBy(Declaration::packageName, TreeMap::new, toList())) // |
| 68 | + .forEach((packageName, packageDeclarations) -> { |
| 69 | + out.println(h5("Package " + packageName)); |
| 70 | + out.println(); |
| 71 | + printDeclarationTableHeader(out); |
| 72 | + packageDeclarations.forEach(it -> printDeclarationTableRow(it, out)); |
| 73 | + printDeclarationTableFooter(out); |
| 74 | + out.println(); |
| 75 | + }); |
| 76 | + }); |
71 | 77 | } |
72 | 78 |
|
73 | 79 | protected void printDeclarationSectionHeader(Set<Status> statuses, Status status, List<Declaration> declarations, |
|
0 commit comments