Skip to content

Commit 90a16b6

Browse files
brunoborgesCopilot
andcommitted
Remove duplicate CATEGORIES list, use SequencedMap for CATEGORY_DISPLAY
Replace separate CATEGORIES List and CATEGORY_DISPLAY Map with a single SequencedMap that provides both ordered iteration and display name lookup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dd9fcf2 commit 90a16b6

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

Generate.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@
3636
static final Pattern TOKEN_PATTERN = Pattern.compile("\\{\\{(\\w+)}}");
3737
static final ObjectMapper MAPPER = new ObjectMapper();
3838

39-
static final List<String> CATEGORIES = List.of(
40-
"language", "collections", "strings", "streams", "concurrency",
41-
"io", "errors", "datetime", "security", "tooling");
42-
43-
static final Map<String, String> CATEGORY_DISPLAY = Map.ofEntries(
44-
Map.entry("language", "Language"),
45-
Map.entry("collections", "Collections"),
46-
Map.entry("strings", "Strings"),
47-
Map.entry("streams", "Streams"),
48-
Map.entry("concurrency", "Concurrency"),
49-
Map.entry("io", "I/O"),
50-
Map.entry("errors", "Errors"),
51-
Map.entry("datetime", "Date/Time"),
52-
Map.entry("security", "Security"),
53-
Map.entry("tooling", "Tooling"));
39+
static final SequencedMap<String, String> CATEGORY_DISPLAY = buildCategoryDisplay();
40+
41+
static SequencedMap<String, String> buildCategoryDisplay() {
42+
var map = new LinkedHashMap<String, String>();
43+
map.put("language", "Language");
44+
map.put("collections", "Collections");
45+
map.put("strings", "Strings");
46+
map.put("streams", "Streams");
47+
map.put("concurrency", "Concurrency");
48+
map.put("io", "I/O");
49+
map.put("errors", "Errors");
50+
map.put("datetime", "Date/Time");
51+
map.put("security", "Security");
52+
map.put("tooling", "Tooling");
53+
return map;
54+
}
5455

5556
static final Set<String> EXCLUDED_KEYS = Set.of("_path", "prev", "next", "related");
5657

@@ -152,7 +153,7 @@ void main() throws IOException {
152153

153154
SequencedMap<String, Snippet> loadAllSnippets() throws IOException {
154155
SequencedMap<String, Snippet> snippets = new LinkedHashMap<>();
155-
for (var cat : CATEGORIES) {
156+
for (var cat : CATEGORY_DISPLAY.sequencedKeySet()) {
156157
var catDir = Path.of(CONTENT_DIR, cat);
157158
if (!Files.isDirectory(catDir)) continue;
158159

site/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"description": "A collection of modern Java code snippets. Every old Java pattern next to its clean, modern replacement — side by side.",
6060
"mainEntity": {
6161
"@type": "ItemList",
62-
"numberOfItems": {{snippetCount}},
62+
"numberOfItems": 85,
6363
"itemListElement": [
6464
{"@type": "ListItem", "position": 1, "url": "https:\/\/javaevolved.github.io\/type-inference-with-var", "name": "Type inference with var"}
6565
,{"@type": "ListItem", "position": 2, "url": "https:\/\/javaevolved.github.io\/text-blocks-for-multiline-strings", "name": "Text blocks for multiline strings"}
@@ -168,7 +168,7 @@
168168
</nav>
169169

170170
<section class="hero">
171-
<div class="hero-badge">{{snippetCount}} modern patterns · Java 8 → Java 25</div>
171+
<div class="hero-badge">85 modern patterns · Java 8 → Java 25</div>
172172
<h1>Java has evolved.<br><span class="gradient">Your code can too.</span></h1>
173173
<p>Every old Java pattern next to its clean, modern replacement — side by side.</p>
174174
<a href="/language/records-for-data-classes.html" class="hero-compare">
@@ -214,7 +214,7 @@ <h1>Java has evolved.<br><span class="gradient">Your code can too.</span></h1>
214214
<section class="section" id="all-comparisons" style="padding-top:24px">
215215
<div class="section-header">
216216
<h2 class="section-title">All comparisons</h2>
217-
<span class="section-badge">{{snippetCount}} snippets</span>
217+
<span class="section-badge">85 snippets</span>
218218
</div>
219219
<div class="filter-pills" id="categoryFilter">
220220
<span class="filter-label">Filter:</span>
@@ -2961,7 +2961,7 @@ <h3>Default interface methods</h3>
29612961

29622962
<div class="stats-bar">
29632963
<div class="stat-card">
2964-
<div class="number orange">{{snippetCount}}</div>
2964+
<div class="number orange">85</div>
29652965
<div class="label">Modern Patterns</div>
29662966
</div>
29672967
<div class="stat-card">

0 commit comments

Comments
 (0)