Skip to content

Commit 538286d

Browse files
committed
Refactor API calls to use Map.of (Java 9+) and List.copyOf (Java 10+)
1 parent 867e58c commit 538286d

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

commonmark/src/main/java/org/commonmark/internal/DocumentParser.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,7 @@ public class DocumentParser implements ParserState {
3131
private static final Map<Class<? extends Block>, BlockParserFactory> NODES_TO_CORE_FACTORIES;
3232

3333
static {
34-
Map<Class<? extends Block>, BlockParserFactory> map = new HashMap<>();
35-
map.put(BlockQuote.class, new BlockQuoteParser.Factory());
36-
map.put(Heading.class, new HeadingParser.Factory());
37-
map.put(FencedCodeBlock.class, new FencedCodeBlockParser.Factory());
38-
map.put(HtmlBlock.class, new HtmlBlockParser.Factory());
39-
map.put(ThematicBreak.class, new ThematicBreakParser.Factory());
40-
map.put(ListBlock.class, new ListBlockParser.Factory());
41-
map.put(IndentedCodeBlock.class, new IndentedCodeBlockParser.Factory());
42-
NODES_TO_CORE_FACTORIES = Collections.unmodifiableMap(map);
34+
NODES_TO_CORE_FACTORIES = Map.of(BlockQuote.class, new BlockQuoteParser.Factory(), Heading.class, new HeadingParser.Factory(), FencedCodeBlock.class, new FencedCodeBlockParser.Factory(), HtmlBlock.class, new HtmlBlockParser.Factory(), ThematicBreak.class, new ThematicBreakParser.Factory(), ListBlock.class, new ListBlockParser.Factory(), IndentedCodeBlock.class, new IndentedCodeBlockParser.Factory());
4335
}
4436

4537
private SourceLine line;

commonmark/src/main/java/org/commonmark/internal/LinkReferenceDefinitionParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ State getState() {
104104
}
105105

106106
List<SourceSpan> removeLines(int lines) {
107-
var removedSpans = Collections.unmodifiableList(new ArrayList<>(
108-
sourceSpans.subList(Math.max(sourceSpans.size() - lines, 0), sourceSpans.size())));
107+
var removedSpans = List.copyOf(sourceSpans.subList(Math.max(sourceSpans.size() - lines, 0), sourceSpans.size()));
109108
removeLast(lines, paragraphLines);
110109
removeLast(lines, sourceSpans);
111110
return removedSpans;

0 commit comments

Comments
 (0)