diff --git a/java/src/org/openqa/selenium/grid/commands/DefaultHubConfig.java b/java/src/org/openqa/selenium/grid/commands/DefaultHubConfig.java index 80f6b585d09d6..a64a50a654ffa 100644 --- a/java/src/org/openqa/selenium/grid/commands/DefaultHubConfig.java +++ b/java/src/org/openqa/selenium/grid/commands/DefaultHubConfig.java @@ -17,22 +17,22 @@ package org.openqa.selenium.grid.commands; -import com.google.common.collect.ImmutableMap; +import java.util.Map; import org.openqa.selenium.grid.config.MapConfig; class DefaultHubConfig extends MapConfig { DefaultHubConfig() { super( - ImmutableMap.of( + Map.of( "events", - ImmutableMap.of( + Map.of( "publish", "tcp://*:4442", "subscribe", "tcp://*:4443", "bind", true), "sessions", - ImmutableMap.of( + Map.of( "implementation", "org.openqa.selenium.grid.sessionmap.local.LocalSessionMap"), - "server", ImmutableMap.of("port", 4444))); + "server", Map.of("port", 4444))); } } diff --git a/java/src/org/openqa/selenium/grid/commands/DefaultStandaloneConfig.java b/java/src/org/openqa/selenium/grid/commands/DefaultStandaloneConfig.java index 946b334b01dfa..f4dfe1ff01c7f 100644 --- a/java/src/org/openqa/selenium/grid/commands/DefaultStandaloneConfig.java +++ b/java/src/org/openqa/selenium/grid/commands/DefaultStandaloneConfig.java @@ -17,18 +17,17 @@ package org.openqa.selenium.grid.commands; -import com.google.common.collect.ImmutableMap; +import java.util.Map; import org.openqa.selenium.grid.config.MapConfig; class DefaultStandaloneConfig extends MapConfig { DefaultStandaloneConfig() { super( - ImmutableMap.of( - "events", - ImmutableMap.of("implementation", "org.openqa.selenium.events.local.GuavaEventBus"), + Map.of( + "events", Map.of("implementation", "org.openqa.selenium.events.local.GuavaEventBus"), "sessions", - ImmutableMap.of( + Map.of( "implementation", "org.openqa.selenium.grid.sessionmap.local.LocalSessionMap"))); } diff --git a/java/src/org/openqa/selenium/grid/commands/EventBusCommand.java b/java/src/org/openqa/selenium/grid/commands/EventBusCommand.java index a52d1099daba3..ccffeca1316a6 100644 --- a/java/src/org/openqa/selenium/grid/commands/EventBusCommand.java +++ b/java/src/org/openqa/selenium/grid/commands/EventBusCommand.java @@ -24,11 +24,10 @@ import static org.openqa.selenium.remote.http.Contents.asJson; import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -70,7 +69,7 @@ public String getDescription() { @Override public Set getConfigurableRoles() { - return ImmutableSet.of(EVENT_BUS_ROLE, HTTPD_ROLE); + return Set.of(EVENT_BUS_ROLE, HTTPD_ROLE); } @Override @@ -91,13 +90,13 @@ protected String getSystemPropertiesConfigPrefix() { @Override protected Config getDefaultConfig() { return new MapConfig( - ImmutableMap.of( + Map.of( "events", - ImmutableMap.of( + Map.of( "bind", true, "publish", "tcp://*:4442", "subscribe", "tcp://*:4443"), - "server", ImmutableMap.of("port", 5557))); + "server", Map.of("port", 5557))); } public Server asServer(Config initialConfig) { @@ -198,9 +197,9 @@ private HttpResponse httpResponse(boolean ready, String message) { .addHeader("Content-Type", JSON_UTF_8) .setContent( asJson( - ImmutableMap.of( + Map.of( "value", - ImmutableMap.of( + Map.of( "ready", ready, "message", message)))); } diff --git a/java/src/org/openqa/selenium/grid/commands/Hub.java b/java/src/org/openqa/selenium/grid/commands/Hub.java index 86733f0524fa9..f6c1b13e20203 100644 --- a/java/src/org/openqa/selenium/grid/commands/Hub.java +++ b/java/src/org/openqa/selenium/grid/commands/Hub.java @@ -27,7 +27,6 @@ import static org.openqa.selenium.remote.http.Route.combine; import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; @@ -88,8 +87,7 @@ public String getDescription() { @Override public Set getConfigurableRoles() { - return ImmutableSet.of( - DISTRIBUTOR_ROLE, EVENT_BUS_ROLE, HTTPD_ROLE, SESSION_QUEUE_ROLE, ROUTER_ROLE); + return Set.of(DISTRIBUTOR_ROLE, EVENT_BUS_ROLE, HTTPD_ROLE, SESSION_QUEUE_ROLE, ROUTER_ROLE); } @Override diff --git a/java/src/org/openqa/selenium/grid/commands/Standalone.java b/java/src/org/openqa/selenium/grid/commands/Standalone.java index 83875cbb59f5f..c2b3cc262594d 100644 --- a/java/src/org/openqa/selenium/grid/commands/Standalone.java +++ b/java/src/org/openqa/selenium/grid/commands/Standalone.java @@ -27,7 +27,6 @@ import static org.openqa.selenium.remote.http.Route.combine; import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -94,8 +93,7 @@ public String getDescription() { @Override public Set getConfigurableRoles() { - return ImmutableSet.of( - DISTRIBUTOR_ROLE, HTTPD_ROLE, NODE_ROLE, ROUTER_ROLE, SESSION_QUEUE_ROLE); + return Set.of(DISTRIBUTOR_ROLE, HTTPD_ROLE, NODE_ROLE, ROUTER_ROLE, SESSION_QUEUE_ROLE); } @Override diff --git a/java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java b/java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java index ccfa4c6c13dc2..2013642d5334c 100644 --- a/java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java +++ b/java/src/org/openqa/selenium/grid/config/AnnotatedConfig.java @@ -18,9 +18,6 @@ package org.openqa.selenium.grid.config; import com.beust.jcommander.Parameter; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; import com.google.common.primitives.Primitives; import java.lang.reflect.Field; import java.util.ArrayDeque; @@ -35,6 +32,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; import org.openqa.selenium.internal.Require; /** @@ -175,17 +173,18 @@ public Optional> getAll(String section, String option) { return Optional.empty(); } - return Optional.of(ImmutableList.copyOf(values)); + return Optional.of(List.copyOf(values)); } @Override public Set getSectionNames() { - return ImmutableSortedSet.copyOf(config.keySet()); + return Collections.unmodifiableSortedSet(new TreeSet<>(config.keySet())); } @Override public Set getOptions(String section) { Require.nonNull("Section name to get options for", section); - return ImmutableSortedSet.copyOf(config.getOrDefault(section, ImmutableMap.of()).keySet()); + return Collections.unmodifiableSortedSet( + new TreeSet<>(config.getOrDefault(section, Map.of()).keySet())); } } diff --git a/java/src/org/openqa/selenium/grid/config/CompoundConfig.java b/java/src/org/openqa/selenium/grid/config/CompoundConfig.java index ce7312e079934..7a653b9e86f6e 100644 --- a/java/src/org/openqa/selenium/grid/config/CompoundConfig.java +++ b/java/src/org/openqa/selenium/grid/config/CompoundConfig.java @@ -17,15 +17,13 @@ package org.openqa.selenium.grid.config; -import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; -import static java.util.Comparator.naturalOrder; - -import com.google.common.collect.ImmutableList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; public class CompoundConfig implements Config { @@ -37,7 +35,7 @@ public CompoundConfig(Config... allConfigsInDescendingOrderOfImportance) { throw new ConfigException("List of config files must be greater than 0."); } - this.allConfigs = ImmutableList.copyOf(allConfigsInDescendingOrderOfImportance); + this.allConfigs = List.of(allConfigsInDescendingOrderOfImportance); } @Override @@ -51,7 +49,7 @@ public Optional> getAll(String section, String option) { .filter(Optional::isPresent) .map(Optional::get) .flatMap(Collection::stream) - .collect(toImmutableList()); + .collect(Collectors.toUnmodifiableList()); return values.isEmpty() ? Optional.empty() : Optional.of(values); } @@ -61,7 +59,9 @@ public Set getSectionNames() { return allConfigs.stream() .map(Config::getSectionNames) .flatMap(Collection::stream) - .collect(toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } @Override @@ -71,6 +71,8 @@ public Set getOptions(String section) { return allConfigs.stream() .map(config -> config.getOptions(section)) .flatMap(Collection::stream) - .collect(toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } } diff --git a/java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java b/java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java index 8b11e2f901d5b..04999b33e275b 100644 --- a/java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java +++ b/java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java @@ -17,17 +17,15 @@ package org.openqa.selenium.grid.config; -import static java.util.Comparator.naturalOrder; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedSet; import java.util.AbstractMap; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; public class ConcatenatingConfig implements Config { @@ -48,7 +46,7 @@ public ConcatenatingConfig(String prefix, char separator, Map values) { entry -> new AbstractMap.SimpleImmutableEntry<>( String.valueOf(entry.getKey()), String.valueOf(entry.getValue()))) - .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)); + .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); } @Override @@ -62,7 +60,7 @@ public Optional> getAll(String section, String option) { .filter(entry -> key.equalsIgnoreCase(entry.getKey())) .map(Map.Entry::getValue) .findFirst() - .map(ImmutableList::of); + .map(List::of); } @Override @@ -76,7 +74,9 @@ public Set getSectionNames() { .filter(key -> key.indexOf(separator) > -1) .map(key -> key.substring(0, key.indexOf(separator))) .map(key -> key.toLowerCase(Locale.ENGLISH)) - .collect(ImmutableSortedSet.toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } @Override @@ -90,6 +90,8 @@ public Set getOptions(String section) { .filter(key -> key.length() > actualPrefix.length() + 1) .map(key -> key.substring(actualPrefix.length())) .map(key -> key.toLowerCase(Locale.ENGLISH)) - .collect(ImmutableSortedSet.toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } } diff --git a/java/src/org/openqa/selenium/grid/config/Config.java b/java/src/org/openqa/selenium/grid/config/Config.java index 2b9e899746311..ac0925e200efa 100644 --- a/java/src/org/openqa/selenium/grid/config/Config.java +++ b/java/src/org/openqa/selenium/grid/config/Config.java @@ -17,7 +17,6 @@ package org.openqa.selenium.grid.config; -import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -95,7 +94,7 @@ default List toEntryList(Map mapItem) { // add record separator entryList.add(DELIMITER); // return immutable config settings list - return ImmutableList.builder().addAll(entryList).build(); + return List.copyOf(entryList); } default String toJson(Object value) { diff --git a/java/src/org/openqa/selenium/grid/config/ConfigFlags.java b/java/src/org/openqa/selenium/grid/config/ConfigFlags.java index 81f44b2dad010..e3df51e0aac07 100644 --- a/java/src/org/openqa/selenium/grid/config/ConfigFlags.java +++ b/java/src/org/openqa/selenium/grid/config/ConfigFlags.java @@ -20,23 +20,22 @@ import static org.openqa.selenium.grid.config.StandardGridRoles.ALL_ROLES; import com.beust.jcommander.Parameter; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; import java.io.PrintStream; import java.nio.file.Path; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import java.util.stream.Collectors; import org.openqa.selenium.json.Json; public class ConfigFlags implements HasRoles { - private static final ImmutableSet IGNORED_SECTIONS = - ImmutableSet.of("java", "lc", "term"); + private static final Set IGNORED_SECTIONS = Set.of("java", "lc", "term"); @Parameter( names = "--config", @@ -61,7 +60,7 @@ public Set getRoles() { public Config readConfigFiles() { if (configFiles == null || configFiles.isEmpty()) { - return new MapConfig(ImmutableMap.of()); + return new MapConfig(Map.of()); } return new CompoundConfig(configFiles.stream().map(Configs::from).toArray(Config[]::new)); @@ -106,12 +105,12 @@ public boolean dumpConfigHelp(Config config, Set currentRoles, PrintStream .collect( Collectors.toMap( DescribedOption::section, - ImmutableSortedSet::of, - (l, r) -> - ImmutableSortedSet.naturalOrder() - .addAll(l) - .addAll(r) - .build())); + option -> Collections.unmodifiableSortedSet(new TreeSet<>(Set.of(option))), + (l, r) -> { + SortedSet merged = new TreeSet<>(l); + merged.addAll(r); + return Collections.unmodifiableSortedSet(merged); + })); StringBuilder demoToml = new StringBuilder(); demoToml.append("Configuration help for Toml config file").append("\n\n"); diff --git a/java/src/org/openqa/selenium/grid/config/DescribedOption.java b/java/src/org/openqa/selenium/grid/config/DescribedOption.java index 3e5aa4e25b133..6ab99604eb5f0 100644 --- a/java/src/org/openqa/selenium/grid/config/DescribedOption.java +++ b/java/src/org/openqa/selenium/grid/config/DescribedOption.java @@ -18,25 +18,23 @@ package org.openqa.selenium.grid.config; import static java.util.Comparator.comparing; -import static java.util.Comparator.naturalOrder; import com.beust.jcommander.Parameter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; -import com.google.common.collect.Sets; -import com.google.common.primitives.Primitives; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; +import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -44,6 +42,18 @@ /** Represents a configurable attribute of the Selenium Grid. */ public class DescribedOption implements Comparable { + private static final Map, Class> PRIMITIVE_TO_WRAPPER = + Map.ofEntries( + Map.entry(boolean.class, Boolean.class), + Map.entry(byte.class, Byte.class), + Map.entry(char.class, Character.class), + Map.entry(double.class, Double.class), + Map.entry(float.class, Float.class), + Map.entry(int.class, Integer.class), + Map.entry(long.class, Long.class), + Map.entry(short.class, Short.class), + Map.entry(void.class, Void.class)); + public final String section; public final String optionName; public final String description; @@ -70,7 +80,7 @@ public class DescribedOption implements Comparable { this.repeats = isCollection(type); this.quotable = isTomlStringType(type); this.example = configValue.example(); - this.flags = ImmutableSortedSet.naturalOrder().add(parameter.names()).build(); + this.flags = Collections.unmodifiableSortedSet(new TreeSet<>(Arrays.asList(parameter.names()))); this.defaultValue = defaultValue; this.hidden = parameter.hidden(); } @@ -78,12 +88,14 @@ public class DescribedOption implements Comparable { public static Set findAllMatchingOptions(Collection roles) { Objects.requireNonNull(roles); - Set minimized = ImmutableSet.copyOf(roles); + Set minimized = Set.copyOf(roles); return StreamSupport.stream(ServiceLoader.load(HasRoles.class).spliterator(), false) - .filter(hasRoles -> !Sets.intersection(hasRoles.getRoles(), minimized).isEmpty()) + .filter(hasRoles -> !Collections.disjoint(hasRoles.getRoles(), minimized)) .flatMap(DescribedOption::getAllFields) - .collect(ImmutableSortedSet.toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } private static Stream getAllFields(HasRoles hasRoles) { @@ -201,7 +213,7 @@ public String getType(Type type) { } private boolean isTomlStringType(Type type) { - Class derived = Primitives.wrap(deriveClass(type)); + Class derived = wrap(deriveClass(type)); // Everything other than numbers and booleans must be quoted return !(Number.class.isAssignableFrom(derived) || Boolean.class.isAssignableFrom(derived)); @@ -230,4 +242,8 @@ private boolean isCollection(Type type) { && ((ParameterizedType) type).getRawType() instanceof Class && Collection.class.isAssignableFrom((Class) ((ParameterizedType) type).getRawType()); } + + private static Class wrap(Class type) { + return (type.isPrimitive()) ? (Class) PRIMITIVE_TO_WRAPPER.get(type) : type; + } } diff --git a/java/src/org/openqa/selenium/grid/config/EnvConfig.java b/java/src/org/openqa/selenium/grid/config/EnvConfig.java index d57f3a548cb49..79b14e8844be0 100644 --- a/java/src/org/openqa/selenium/grid/config/EnvConfig.java +++ b/java/src/org/openqa/selenium/grid/config/EnvConfig.java @@ -17,14 +17,13 @@ package org.openqa.selenium.grid.config; -import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; -import static java.util.Comparator.naturalOrder; - -import com.google.common.collect.ImmutableList; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; /** @@ -54,7 +53,7 @@ public Optional> getAll(String section, String option) { value = System.getenv(value.substring(1)); } - return Optional.ofNullable(value).map(ImmutableList::of); + return Optional.ofNullable(value).map(List::of); } @Override @@ -64,7 +63,9 @@ public Set getSectionNames() { .filter(key -> key.split("_").length > 1) .map(key -> key.substring(0, key.indexOf('_'))) .map(key -> key.toLowerCase(Locale.ENGLISH)) - .collect(toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } @Override @@ -76,6 +77,8 @@ public Set getOptions(String section) { .filter(key -> key.startsWith(prefix)) .map(key -> key.substring(prefix.length())) .map(key -> key.toLowerCase(Locale.ENGLISH)) - .collect(toImmutableSortedSet(naturalOrder())); + .collect( + Collectors.collectingAndThen( + Collectors.toCollection(TreeSet::new), Collections::unmodifiableSortedSet)); } } diff --git a/java/src/org/openqa/selenium/grid/config/MapConfig.java b/java/src/org/openqa/selenium/grid/config/MapConfig.java index b971de4298b2e..d233879e4bfb1 100644 --- a/java/src/org/openqa/selenium/grid/config/MapConfig.java +++ b/java/src/org/openqa/selenium/grid/config/MapConfig.java @@ -17,15 +17,15 @@ package org.openqa.selenium.grid.config; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSortedSet; import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; public class MapConfig implements Config { @@ -35,24 +35,25 @@ public class MapConfig implements Config { public MapConfig(Map raw) { Require.nonNull("Underlying map", raw); - ImmutableMap.Builder> builder = ImmutableMap.builder(); + Map> validated = new HashMap<>(); + for (Map.Entry entry : raw.entrySet()) { if (!(entry.getValue() instanceof Map)) { continue; } - ImmutableMap values = + Map values = ((Map) entry.getValue()) .entrySet().stream() .filter(e -> e.getKey() instanceof String) .collect( - ImmutableMap.toImmutableMap( + Collectors.toUnmodifiableMap( e -> String.valueOf(e.getKey()), Map.Entry::getValue)); - builder.put(entry.getKey(), values); + validated.put(entry.getKey(), values); } - this.raw = builder.build(); + this.raw = Collections.unmodifiableMap(validated); } @Override @@ -79,33 +80,33 @@ public Optional> getAll(String section, String option) { .map(item -> (Map) item) .map(this::toEntryList) .flatMap(Collection::stream) - .collect(ImmutableList.toImmutableList())); + .collect(Collectors.toUnmodifiableList())); } return Optional.of( collection.stream() .filter(item -> (!(item instanceof Collection))) .map(String::valueOf) - .collect(ImmutableList.toImmutableList())); + .collect(Collectors.toUnmodifiableList())); } if (value instanceof Map) { return Optional.of(toEntryList((Map) value)); } - return Optional.of(ImmutableList.of(String.valueOf(value))); + return Optional.of(List.of(String.valueOf(value))); } @Override public Set getSectionNames() { - return ImmutableSet.copyOf(raw.keySet()); + return Set.copyOf(raw.keySet()); } @Override public Set getOptions(String section) { Require.nonNull("Section name to get options for", section); - Map values = raw.getOrDefault(section, ImmutableMap.of()); - return ImmutableSortedSet.copyOf(values.keySet()); + Map values = raw.getOrDefault(section, Map.of()); + return Collections.unmodifiableSortedSet(new TreeSet<>(values.keySet())); } } diff --git a/java/src/org/openqa/selenium/grid/config/TomlConfig.java b/java/src/org/openqa/selenium/grid/config/TomlConfig.java index 991c6a9f42fa2..a52dab367e3be 100644 --- a/java/src/org/openqa/selenium/grid/config/TomlConfig.java +++ b/java/src/org/openqa/selenium/grid/config/TomlConfig.java @@ -17,16 +17,16 @@ package org.openqa.selenium.grid.config; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSortedSet; import java.io.IOException; import java.io.Reader; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.TreeSet; import java.util.stream.Collectors; import org.openqa.selenium.internal.Require; import org.tomlj.Toml; @@ -108,14 +108,14 @@ public Optional> getAll(String section, String option) { .map(TomlTable::toMap) .map(this::toEntryList) .flatMap(Collection::stream) - .collect(ImmutableList.toImmutableList())); + .collect(Collectors.toUnmodifiableList())); } return Optional.of( collection.stream() .filter(item -> (!(item instanceof Collection))) .map(String::valueOf) - .collect(ImmutableList.toImmutableList())); + .collect(Collectors.toUnmodifiableList())); } if (value instanceof TomlTable) { @@ -127,7 +127,7 @@ public Optional> getAll(String section, String option) { @Override public Set getSectionNames() { - return ImmutableSortedSet.copyOf(toml.keySet()); + return Collections.unmodifiableSortedSet(new TreeSet<>(toml.keySet())); } @Override @@ -136,9 +136,9 @@ public Set getOptions(String section) { Object raw = toml.get(section); if (!(raw instanceof TomlTable)) { - return ImmutableSortedSet.of(); + return Collections.emptySortedSet(); } - return ImmutableSortedSet.copyOf(((TomlTable) raw).keySet()); + return Collections.unmodifiableSortedSet(new TreeSet<>(((TomlTable) raw).keySet())); } }