Skip to content

Commit a23bc9f

Browse files
authored
[java] Removing old stream collectors required by Java 8 (#15523)
1 parent f0c392c commit a23bc9f

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

java/src/org/openqa/selenium/PersistentCapabilities.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
package org.openqa.selenium;
1919

20-
import java.util.Collections;
2120
import java.util.Map;
2221
import java.util.Set;
2322
import java.util.function.Function;
24-
import java.util.stream.Collector;
2523
import java.util.stream.Collectors;
2624
import java.util.stream.Stream;
2725
import org.openqa.selenium.internal.Require;
@@ -58,7 +56,7 @@ public PersistentCapabilities setCapability(String name, Object value) {
5856
@Override
5957
public Map<String, Object> asMap() {
6058
return getCapabilityNames().stream()
61-
.collect(toUnmodifiableMap(Function.identity(), this::getCapability));
59+
.collect(Collectors.toUnmodifiableMap(Function.identity(), this::getCapability));
6260
}
6361

6462
@Override
@@ -81,19 +79,7 @@ public Capabilities merge(Capabilities other) {
8179
public Set<String> getCapabilityNames() {
8280
return Stream.concat(
8381
caps.getCapabilityNames().stream(), overrides.getCapabilityNames().stream())
84-
.collect(toUnmodifiableSet());
85-
}
86-
87-
// Needed, since we're dependent on Java 8 as a minimum version
88-
private <T, K, U> Collector<T, ?, Map<K, U>> toUnmodifiableMap(
89-
Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) {
90-
return Collectors.collectingAndThen(
91-
Collectors.toMap(keyMapper, valueMapper), Collections::unmodifiableMap);
92-
}
93-
94-
// Needed, since we're dependent on Java 8 as a minimum version
95-
private <T> Collector<T, ?, Set<T>> toUnmodifiableSet() {
96-
return Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet);
82+
.collect(Collectors.toUnmodifiableSet());
9783
}
9884

9985
@Override

0 commit comments

Comments
 (0)