Skip to content

Commit

Permalink
Use Collection.copyOf instead of Guava's Immutable*.copyOf
Browse files Browse the repository at this point in the history
Change-Id: Iefc01a4db4e901d519ef149b1eaa45c0e577bf5a
  • Loading branch information
akurtakov committed Mar 15, 2022
1 parent 2f0cc66 commit 9ad0273
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Jeremie Bresson and others.
* Copyright (c) 2017, 2022 Jeremie Bresson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -19,8 +19,6 @@

import org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguageConfiguration;

import com.google.common.collect.ImmutableMap;

/**
* Extended configuration for the AsciiDoc markup language
*
Expand All @@ -46,6 +44,6 @@ public Map<String, String> getInitialAttributes() {
*/
public void setInitialAttributes(Map<String, String> initialAttributes) {
Objects.requireNonNull(initialAttributes, "initialAttributes can not be null");
this.initialAttributes = ImmutableMap.copyOf(initialAttributes);
this.initialAttributes = Map.copyOf(initialAttributes);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 David Green.
* Copyright (c) 2015, 2022 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -15,11 +15,11 @@

import static java.util.Objects.requireNonNull;

import java.util.Map;

import org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser;
import org.eclipse.mylyn.wikitext.parser.IdGenerator;

import com.google.common.collect.ImmutableMap;

public class ProcessingContext {

public static ProcessingContextBuilder builder() {
Expand Down Expand Up @@ -55,12 +55,11 @@ public String getTitle() {

private final InlineParser inlineParser;

private final ImmutableMap<String, NamedUriWithTitle> links;
private final Map<String, NamedUriWithTitle> links;

private final IdGenerator idGenerator;

ProcessingContext(InlineParser inlineParser, ImmutableMap<String, NamedUriWithTitle> links,
IdGenerator idGenerator) {
ProcessingContext(InlineParser inlineParser, Map<String, NamedUriWithTitle> links, IdGenerator idGenerator) {
this.inlineParser = requireNonNull(inlineParser);
this.links = requireNonNull(links);
this.idGenerator = requireNonNull(idGenerator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.mylyn.wikitext.parser.markup.IdGenerationStrategy;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;

public class ProcessingContextBuilder {

Expand All @@ -49,7 +48,7 @@ public ProcessingContextBuilder idGenerationStrategy(IdGenerationStrategy idGene
}

public ProcessingContext build() {
return new ProcessingContext(getInlineParser(), ImmutableMap.copyOf(linkByName), idGenerator());
return new ProcessingContext(getInlineParser(), Map.copyOf(linkByName), idGenerator());
}

public ProcessingContextBuilder inlineParser(InlineParser inlineParser) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2021 David Green.
* Copyright (c) 2015, 2022 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -23,8 +23,6 @@
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder;

import com.google.common.collect.ImmutableList;

public class SourceBlocks extends SourceBlock {

public static class BlockContext {
Expand Down Expand Up @@ -61,7 +59,7 @@ public SourceBlocks(SourceBlock... blocks) {
}

SourceBlocks(List<SourceBlock> supportedBlocks) {
this.supportedBlocks = ImmutableList.copyOf(supportedBlocks);
this.supportedBlocks = List.copyOf(supportedBlocks);
}

private interface SourceBlockRunnable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 David Green.
* Copyright (c) 2015, 2022 David Green.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -27,8 +27,6 @@
import org.eclipse.mylyn.wikitext.parser.builder.EntityReferences;
import org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder;

import com.google.common.collect.ImmutableList;

public class InlineParser {

private final List<SourceSpan> spans;
Expand All @@ -38,7 +36,7 @@ public class InlineParser {
}

public InlineParser(List<SourceSpan> spans) {
this.spans = ImmutableList.copyOf(spans);
this.spans = List.copyOf(spans);
}

public void emit(ProcessingContext context, DocumentBuilder builder, TextSegment textSegment) {
Expand Down Expand Up @@ -76,7 +74,7 @@ public List<Inline> parse(ProcessingContext context, TextSegment segment) {
}

static List<Inline> secondPass(List<Inline> inlines) {
List<Inline> processedInlines = ImmutableList.copyOf(inlines);
List<Inline> processedInlines = List.copyOf(inlines);
Optional<InlinesSubstitution> substitution = Optional.empty();
do {
for (Inline inline : processedInlines) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 David Green.
* Copyright (c) 2015, 2022 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -20,15 +20,13 @@

import org.eclipse.mylyn.wikitext.commonmark.internal.Line;

import com.google.common.collect.ImmutableList;

public abstract class InlineWithNestedContents extends Inline {

private final List<Inline> contents;

public InlineWithNestedContents(Line line, int offset, int length, List<Inline> contents) {
super(line, offset, length);
this.contents = ImmutableList.copyOf(contents);
this.contents = List.copyOf(contents);
}

public List<Inline> getContents() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 David Green.
* Copyright (c) 2015, 2022 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -30,7 +30,7 @@ class InlinesSubstitution {
public InlinesSubstitution(Inline first, Inline last, List<Inline> substitution) {
this.first = requireNonNull(first);
this.last = requireNonNull(last);
this.substitution = ImmutableList.copyOf(substitution);
this.substitution = List.copyOf(substitution);
}

public List<Inline> apply(List<Inline> inlines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

class BlockStrategies extends ElementStrategies<BlockType, BlockStrategy, HtmlElementStrategy<BlockType>> {

Expand All @@ -52,7 +51,7 @@ private static Map<BlockType, List<BlockType>> createBlockTypeToAlternatives() {
addAlternatives(alternatives, BlockType.TABLE_CELL_NORMAL, BlockType.PARAGRAPH, BlockType.DIV);
addAlternatives(alternatives, BlockType.TIP, BlockType.PARAGRAPH, BlockType.DIV);
addAlternatives(alternatives, BlockType.WARNING, BlockType.PARAGRAPH, BlockType.DIV);
return ImmutableMap.copyOf(alternatives);
return Map.copyOf(alternatives);
}

private static void addAlternatives(Map<BlockType, List<BlockType>> alternatives, BlockType blockType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

class CompositeSpanStrategy implements SpanStrategy {

private final List<SpanStrategy> delegates;

CompositeSpanStrategy(List<SpanStrategy> delegates) {
this.delegates = ImmutableList.copyOf(delegates);
this.delegates = List.copyOf(delegates);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

import org.eclipse.mylyn.wikitext.parser.Attributes;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

abstract class ElementStrategies<ElementType extends Enum<ElementType>, ElementStrategy, HtmlElementStrategyType extends HtmlElementStrategy<ElementType>> {

private Map<ElementType, ElementStrategy> elementStrategyByElementType;
Expand All @@ -36,7 +33,7 @@ abstract class ElementStrategies<ElementType extends Enum<ElementType>, ElementS
List<HtmlElementStrategyType> elementStrategies) {
requireNonNull(elementTypeClass);
requireNonNull(elementTypes);
this.elementStrategies = ImmutableList.copyOf(requireNonNull(elementStrategies));
this.elementStrategies = List.copyOf(requireNonNull(elementStrategies));

initialize(elementTypeClass, elementTypes);
}
Expand Down Expand Up @@ -70,7 +67,7 @@ private void initialize(Class<ElementType> elementTypeClass, Set<ElementType> el
}
elementStrategyByElementType.putAll(alternativesByElementType);

this.elementStrategyByElementType = ImmutableMap.copyOf(elementStrategyByElementType);
this.elementStrategyByElementType = Map.copyOf(elementStrategyByElementType);
}

abstract void addImplicitElementTypes(Map<ElementType, ElementStrategy> blockStrategyByElementType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType;
import org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentHandler;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

public class HtmlSubsetLanguage extends HtmlLanguage {

private final Set<BlockType> supportedBlockTypes;
Expand All @@ -57,10 +53,10 @@ public HtmlSubsetLanguage(String name, HtmlDocumentHandler documentHandler, int
this.documentHandler = documentHandler;
checkArgument(headingLevel >= 0 && headingLevel <= 6, "headingLevel must be between 0 and 6"); //$NON-NLS-1$
this.headingLevel = headingLevel;
this.supportedBlockTypes = ImmutableSet.copyOf(requireNonNull(blockTypes));
this.supportedSpanTypes = ImmutableSet.copyOf(requireNonNull(spanTypes));
this.tagNameSubstitutions = ImmutableMap.copyOf(requireNonNull(tagNameSubstitutions));
this.spanElementStrategies = ImmutableList.copyOf(requireNonNull(spanElementStrategies));
this.supportedBlockTypes = Set.copyOf(requireNonNull(blockTypes));
this.supportedSpanTypes = Set.copyOf(requireNonNull(spanTypes));
this.tagNameSubstitutions = Map.copyOf(requireNonNull(tagNameSubstitutions));
this.spanElementStrategies = List.copyOf(requireNonNull(spanElementStrategies));
this.xhtmlStrict = xhtmlStrict;
this.supportsImages = supportsImages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

public class SpanStrategies extends ElementStrategies<SpanType, SpanStrategy, SpanHtmlElementStrategy> {

Expand All @@ -48,7 +47,7 @@ private static Map<SpanType, List<SpanType>> createSpanTypeToAlternatives() {
addAlternatives(alternatives, SpanType.INSERTED, SpanType.UNDERLINED);
addAlternatives(alternatives, SpanType.ITALIC, SpanType.EMPHASIS);
addAlternatives(alternatives, SpanType.MONOSPACE, SpanType.CODE);
return ImmutableMap.copyOf(alternatives);
return Map.copyOf(alternatives);
}

private static void addAlternatives(Map<SpanType, List<SpanType>> alternatives, SpanType spanType,
Expand Down Expand Up @@ -124,7 +123,7 @@ private SpanStrategy calculateAlternateSpanStrategy(Attributes attributes) {
}
}
}
strategies = ImmutableList.copyOf(strategies.stream().filter(Objects::nonNull).collect(Collectors.toList()));
strategies = List.copyOf(strategies.stream().filter(Objects::nonNull).collect(Collectors.toList()));
if (strategies.isEmpty()) {
return null;
} else if (strategies.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
import java.net.URL;
import java.util.Map;

import com.google.common.collect.ImmutableMap;

public class TestMediaWikiApiImageFetchingStrategy extends MediaWikiApiImageFetchingStrategy {

private final Map<String, String> serverContent;

public TestMediaWikiApiImageFetchingStrategy(Map<String, String> serverContent) {
requireNonNull(serverContent,
"Please specify some server content for images used during the tests. See: TestMediaWikiApiImageFetchingStrategy#serverContent");
this.serverContent = ImmutableMap.copyOf(serverContent);
this.serverContent = Map.copyOf(serverContent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

import java.util.Map;

import com.google.common.collect.ImmutableMap;

public class TestMediaWikiImageFetcher extends MediaWikiImageFetcher {
private Map<String, String> imageServerContent;

public void setImageServerContent(Map<String, String> serverContent) {
this.imageServerContent = ImmutableMap.copyOf(serverContent);
this.imageServerContent = Map.copyOf(serverContent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import org.apache.tools.ant.Project;

import com.google.common.collect.ImmutableMap;

/**
* Extension of the {@link WikiToDocTask} for test purposes.
*/
Expand All @@ -46,7 +44,7 @@ public void setServerContent(Map<String, String> serverContent) {
}

public void setImageServerContent(Map<String, String> imageServerContent) {
this.imageServerContent = ImmutableMap.copyOf(imageServerContent);
this.imageServerContent = Map.copyOf(imageServerContent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2021 David Green and others.
* Copyright (c) 2007, 2022 David Green and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -110,7 +110,7 @@ public class HtmlDocumentBuilder extends AbstractXmlDocumentBuilder {
"border: 1px solid #ccc;background-color: #FFFFCE;margin: 10px;padding: 0px 6px 0px 6px;")) //$NON-NLS-1$
);

private Map<SpanType, String> spanTypeToElementName = ImmutableMap.copyOf(defaultSpanTypeToElementName);
private Map<SpanType, String> spanTypeToElementName = Map.copyOf(defaultSpanTypeToElementName);

private String htmlNsUri = "http://www.w3.org/1999/xhtml"; //$NON-NLS-1$

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013 Tasktop Technologies and others.
* Copyright (c) 2013, 2022 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -21,8 +21,6 @@
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder;
import org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder;

import com.google.common.collect.ImmutableList;

/**
* Captures the result of a {@link EventDocumentBuilder} as a series of {@link DocumentBuilderEvent events}.
*
Expand All @@ -35,7 +33,7 @@ public class DocumentBuilderEvents {
private final List<DocumentBuilderEvent> events;

public DocumentBuilderEvents(List<DocumentBuilderEvent> events) {
this.events = ImmutableList.copyOf(Objects.requireNonNull(events, "Must provide events")); //$NON-NLS-1$
this.events = List.copyOf(Objects.requireNonNull(events, "Must provide events")); //$NON-NLS-1$
}

public List<DocumentBuilderEvent> getEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.eclipse.mylyn.wikitext.parser.MarkupParser;
import org.eclipse.mylyn.wikitext.util.ServiceLocator;

import com.google.common.collect.ImmutableSet;

/**
* A markup language, which knows its formatting rules and is able to process content based on {@link Block},
* {@link PatternBasedElementProcessor} and {@link PatternBasedElement} concepts. All markup languages supported by
Expand Down Expand Up @@ -130,7 +128,7 @@ public Set<String> getFileExtensions() {
public void setFileExtensions(Set<String> fileExtensions) {
Objects.requireNonNull(fileExtensions, "Must specify file extensions"); //$NON-NLS-1$
checkArgument(!fileExtensions.isEmpty(), "File extensions must not be empty"); //$NON-NLS-1$
this.fileExtensions = ImmutableSet.copyOf(fileExtensions);
this.fileExtensions = Set.copyOf(fileExtensions);
}

/**
Expand Down
Loading

0 comments on commit 9ad0273

Please sign in to comment.