Skip to content

Commit b79bcd3

Browse files
committed
Use older APIs
1 parent 132784c commit b79bcd3

40 files changed

Lines changed: 206 additions & 124 deletions

File tree

‎commonmark-ext-autolink/src/main/java/org/commonmark/ext/autolink/AutolinkExtension.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.autolink;
22

3+
import java.util.Arrays;
34
import java.util.EnumSet;
45
import java.util.Set;
56
import org.commonmark.Extension;
@@ -57,7 +58,12 @@ public Builder linkTypes(AutolinkType... linkTypes) {
5758
throw new NullPointerException("linkTypes must not be null");
5859
}
5960

60-
return this.linkTypes(Set.of(linkTypes));
61+
if (linkTypes.length == 0) {
62+
throw new IllegalArgumentException("linkTypes must not be empty");
63+
}
64+
65+
this.linkTypes = EnumSet.copyOf(Arrays.asList(linkTypes));
66+
return this;
6167
}
6268

6369
/**

‎commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/FootnotesExtension.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.footnotes;
22

3+
import java.util.Collections;
34
import java.util.Set;
45
import org.commonmark.Extension;
56
import org.commonmark.ext.footnotes.internal.*;
@@ -83,7 +84,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {
8384

8485
@Override
8586
public Set<Character> getSpecialCharacters() {
86-
return Set.of();
87+
return Collections.emptySet();
8788
}
8889
});
8990
}

‎commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/internal/FootnoteBlockParser.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.footnotes.internal;
22

3+
import java.util.Collections;
34
import java.util.List;
45
import org.commonmark.ext.footnotes.FootnoteDefinition;
56
import org.commonmark.node.Block;
@@ -54,7 +55,7 @@ public BlockContinue tryContinue(ParserState parserState) {
5455
public List<DefinitionMap<?>> getDefinitions() {
5556
var map = new DefinitionMap<>(FootnoteDefinition.class);
5657
map.putIfAbsent(block.getLabel(), block);
57-
return List.of(map);
58+
return Collections.singletonList(map);
5859
}
5960

6061
public static class Factory implements BlockParserFactory {

‎commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/internal/FootnoteHtmlNodeRenderer.java‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ public FootnoteHtmlNodeRenderer(HtmlNodeRendererContext context) {
8282

8383
@Override
8484
public Set<Class<? extends Node>> getNodeTypes() {
85-
return Set.of(FootnoteReference.class, InlineFootnote.class, FootnoteDefinition.class);
85+
return Collections.unmodifiableSet(
86+
new HashSet<>(
87+
Arrays.asList(
88+
FootnoteReference.class,
89+
InlineFootnote.class,
90+
FootnoteDefinition.class)));
8691
}
8792

8893
@Override
@@ -203,7 +208,10 @@ private ReferenceInfo registerReference(Node node, String label) {
203208
}
204209

205210
private void renderReference(Node node, ReferenceInfo referenceInfo) {
206-
html.tag("sup", context.extendAttributes(node, "sup", Map.of("class", "footnote-ref")));
211+
html.tag(
212+
"sup",
213+
context.extendAttributes(
214+
node, "sup", Collections.singletonMap("class", "footnote-ref")));
207215

208216
var href = "#" + referenceInfo.definitionId;
209217
var attrs = new LinkedHashMap<String, String>();
@@ -231,7 +239,7 @@ private void renderDefinition(Node def, ReferencedDefinition referencedDefinitio
231239
// Because we're manually rendering the <p> for the last paragraph, do the same
232240
// for all other paragraphs for consistency (Paragraph rendering might be
233241
// overwritten by a custom renderer).
234-
html.tag("p", context.extendAttributes(node, "p", Map.of()));
242+
html.tag("p", context.extendAttributes(node, "p", Collections.emptyMap()));
235243
renderChildren(node);
236244
html.tag("/p");
237245
html.line();
@@ -241,14 +249,14 @@ private void renderDefinition(Node def, ReferencedDefinition referencedDefinitio
241249
node = node.getNext();
242250
}
243251

244-
html.tag("p", context.extendAttributes(lastParagraph, "p", Map.of()));
252+
html.tag("p", context.extendAttributes(lastParagraph, "p", Collections.emptyMap()));
245253
renderChildren(lastParagraph);
246254
html.raw(" ");
247255
renderBackrefs(def, referencedDefinition);
248256
html.tag("/p");
249257
html.line();
250258
} else if (def instanceof InlineFootnote) {
251-
html.tag("p", context.extendAttributes(def, "p", Map.of()));
259+
html.tag("p", context.extendAttributes(def, "p", Collections.emptyMap()));
252260
renderChildren(def);
253261
html.raw(" ");
254262
renderBackrefs(def, referencedDefinition);
@@ -283,7 +291,8 @@ private void renderBackrefs(Node def, ReferencedDefinition referencedDefinition)
283291
if (refNumber > 1) {
284292
html.tag(
285293
"sup",
286-
context.extendAttributes(def, "sup", Map.of("class", "footnote-ref")));
294+
context.extendAttributes(
295+
def, "sup", Collections.singletonMap("class", "footnote-ref")));
287296
html.raw(String.valueOf(refNumber));
288297
html.tag("/sup");
289298
}

‎commonmark-ext-footnotes/src/main/java/org/commonmark/ext/footnotes/internal/FootnoteMarkdownNodeRenderer.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.commonmark.ext.footnotes.internal;
22

3+
import java.util.Arrays;
4+
import java.util.Collections;
5+
import java.util.HashSet;
36
import java.util.Set;
47
import org.commonmark.ext.footnotes.FootnoteDefinition;
58
import org.commonmark.ext.footnotes.FootnoteReference;
@@ -21,7 +24,12 @@ public FootnoteMarkdownNodeRenderer(MarkdownNodeRendererContext context) {
2124

2225
@Override
2326
public Set<Class<? extends Node>> getNodeTypes() {
24-
return Set.of(FootnoteReference.class, InlineFootnote.class, FootnoteDefinition.class);
27+
return Collections.unmodifiableSet(
28+
new HashSet<>(
29+
Arrays.asList(
30+
FootnoteReference.class,
31+
InlineFootnote.class,
32+
FootnoteDefinition.class)));
2533
}
2634

2735
@Override

‎commonmark-ext-gfm-alerts/src/main/java/org/commonmark/ext/gfm/alerts/AlertsExtension.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.gfm.alerts;
22

3+
import java.util.Collections;
34
import java.util.HashMap;
45
import java.util.HashSet;
56
import java.util.Locale;
@@ -121,7 +122,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {
121122

122123
@Override
123124
public Set<Character> getSpecialCharacters() {
124-
return Set.of();
125+
return Collections.emptySet();
125126
}
126127
});
127128
}

‎commonmark-ext-gfm-alerts/src/main/java/org/commonmark/ext/gfm/alerts/internal/AlertBlockParser.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.commonmark.ext.gfm.alerts.internal;
22

3-
import java.util.List;
3+
import java.util.Collections;
44
import java.util.Locale;
55
import java.util.Set;
66
import java.util.regex.Pattern;
@@ -91,7 +91,7 @@ public void parseInlines(InlineParser inlineParser) {
9191
// Set source spans on the title node from the source line
9292
var sourceSpan = titleLine.getSourceSpan();
9393
if (sourceSpan != null) {
94-
titleNode.setSourceSpans(List.of(sourceSpan));
94+
titleNode.setSourceSpans(Collections.singletonList(sourceSpan));
9595
}
9696

9797
// Body blocks were attached as children during block parsing. Prepend the title.

‎commonmark-ext-gfm-alerts/src/main/java/org/commonmark/ext/gfm/alerts/internal/AlertHtmlNodeRenderer.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.gfm.alerts.internal;
22

3+
import java.util.Collections;
34
import java.util.LinkedHashMap;
45
import java.util.Map;
56
import org.commonmark.ext.gfm.alerts.Alert;
@@ -40,7 +41,9 @@ protected void renderAlert(Alert alert) {
4041

4142
// Render alert title
4243
htmlWriter.tag(
43-
"p", context.extendAttributes(alert, "p", Map.of("class", "markdown-alert-title")));
44+
"p",
45+
context.extendAttributes(
46+
alert, "p", Collections.singletonMap("class", "markdown-alert-title")));
4447
var first = alert.getFirstChild();
4548
if (first instanceof AlertTitle) {
4649
renderChildren(first);

‎commonmark-ext-gfm-alerts/src/main/java/org/commonmark/ext/gfm/alerts/internal/AlertNodeRenderer.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.gfm.alerts.internal;
22

3+
import java.util.Collections;
34
import java.util.Set;
45
import org.commonmark.ext.gfm.alerts.Alert;
56
import org.commonmark.ext.gfm.alerts.AlertTitle;
@@ -10,7 +11,7 @@ public abstract class AlertNodeRenderer implements NodeRenderer {
1011

1112
@Override
1213
public Set<Class<? extends Node>> getNodeTypes() {
13-
return Set.of(Alert.class);
14+
return Collections.singleton(Alert.class);
1415
}
1516

1617
@Override

‎commonmark-ext-gfm-strikethrough/src/main/java/org/commonmark/ext/gfm/strikethrough/StrikethroughExtension.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.commonmark.ext.gfm.strikethrough;
22

3+
import java.util.Collections;
34
import java.util.Set;
45
import org.commonmark.Extension;
56
import org.commonmark.ext.gfm.strikethrough.internal.StrikethroughDelimiterProcessor;
@@ -96,7 +97,7 @@ public NodeRenderer create(MarkdownNodeRendererContext context) {
9697

9798
@Override
9899
public Set<Character> getSpecialCharacters() {
99-
return Set.of('~');
100+
return Collections.singleton('~');
100101
}
101102
});
102103
}

0 commit comments

Comments
 (0)