Skip to content

Commit 138e3ab

Browse files
asashourbarancev
authored andcommitted
Fix generics
Signed-off-by: Alexei Barantsev <barancev@gmail.com>
1 parent 1fee32b commit 138e3ab

File tree

16 files changed

+36
-34
lines changed

16 files changed

+36
-34
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private FirefoxDriver(
193193
}
194194

195195
private static CommandExecutor toExecutor(FirefoxOptions options) {
196-
DriverService.Builder builder;
196+
DriverService.Builder<?, ?> builder;
197197

198198
if (options.isLegacy()) {
199199
builder = XpiDriverService.builder()

java/client/src/org/openqa/selenium/firefox/FirefoxOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static FirefoxOptions fromJsonMap(Map<String, Object> map) throws IOException {
9696

9797
if (map.containsKey("args")) {
9898
@SuppressWarnings("unchecked") // #YOLO
99-
List<String> list = (List) getOption(map, "args", List.class);
99+
List<String> list = (List<String>) getOption(map, "args", List.class);
100100
options.addArguments(list);
101101
}
102102

@@ -114,7 +114,7 @@ static FirefoxOptions fromJsonMap(Map<String, Object> map) throws IOException {
114114

115115
if (map.containsKey("prefs")) {
116116
@SuppressWarnings("unchecked") // #YOLO
117-
Map<String, Object> prefs = (Map) getOption(map, "prefs", Map.class);
117+
Map<String, Object> prefs = (Map<String, Object>) getOption(map, "prefs", Map.class);
118118
prefs.forEach((key, value) -> {
119119
if (value instanceof Boolean) {
120120
options.addPreference(key, (Boolean) value);

java/client/src/org/openqa/selenium/remote/JdkAugmenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected RemoteWebDriver extractRemoteWebDriver(WebDriver driver) {
5656
} else if (Proxy.isProxyClass(driver.getClass())) {
5757
InvocationHandler handler = Proxy.getInvocationHandler(driver);
5858
if (handler instanceof JdkHandler) {
59-
return ((JdkHandler) handler).driver;
59+
return ((JdkHandler<?>) handler).driver;
6060
}
6161
}
6262
return null;

java/client/src/org/openqa/selenium/remote/JsonToBeanConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ private Object convertJsonPrimitive(JsonPrimitive json) {
256256
}
257257
}
258258

259-
private Enum convertEnum(Class clazz, Object text) {
259+
private Enum<?> convertEnum(Class<?> clazz, Object text) {
260260
String toConvert = text instanceof JsonElement ?
261261
((JsonElement) text).getAsString() : String.valueOf(text);
262262

263-
Function<Class, Enum<?>> asEnum = (c) -> {
263+
Function<Class<?>, Enum<?>> asEnum = (c) -> {
264264
for (Object value : c.getEnumConstants()) {
265265
if (value.toString().equalsIgnoreCase(toConvert)) {
266266
return (Enum<?>) value;
@@ -273,8 +273,8 @@ private Enum convertEnum(Class clazz, Object text) {
273273
return asEnum.apply(clazz);
274274
}
275275

276-
Class[] allClasses = clazz.getClasses();
277-
for (Class current : allClasses) {
276+
Class<?>[] allClasses = clazz.getClasses();
277+
for (Class<?> current : allClasses) {
278278
if (current.isEnum()) {
279279
return asEnum.apply(current);
280280
}

java/client/src/org/openqa/selenium/remote/http/AbstractHttpCommandCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public abstract class AbstractHttpCommandCodec implements CommandCodec<HttpReque
119119
private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings();
120120
private static final String SESSION_ID_PARAM = "sessionId";
121121

122-
private final ConcurrentHashMap<String, CommandSpec> nameToSpec = new ConcurrentHashMap();
122+
private final ConcurrentHashMap<String, CommandSpec> nameToSpec = new ConcurrentHashMap<>();
123123
private final Map<String, String> aliases = new HashMap<>();
124124
private final BeanToJsonConverter beanToJsonConverter = new BeanToJsonConverter();
125125
private final JsonToBeanConverter jsonToBeanConverter = new JsonToBeanConverter();

java/client/src/org/openqa/selenium/remote/service/DriverService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ protected OutputStream getOutputStream() {
237237
return outputStream;
238238
}
239239

240-
public static abstract class Builder<DS extends DriverService, B extends Builder> {
240+
public static abstract class Builder<DS extends DriverService, B extends Builder<?, ?>> {
241241

242242
private int port = 0;
243243
private File exe = null;
@@ -250,6 +250,7 @@ public static abstract class Builder<DS extends DriverService, B extends Builder
250250
* @param file The executable to use.
251251
* @return A self reference.
252252
*/
253+
@SuppressWarnings("unchecked")
253254
public B usingDriverExecutable(File file) {
254255
checkNotNull(file);
255256
checkExecutable(file);

java/client/src/org/openqa/selenium/safari/SafariOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static SafariOptions fromCapabilities(Capabilities capabilities)
9090
return (SafariOptions) cap;
9191
} else if (cap instanceof Map) {
9292
try {
93-
return SafariOptions.fromJsonMap((Map) cap);
93+
return SafariOptions.fromJsonMap((Map<?, ?>) cap);
9494
} catch (IOException e) {
9595
throw new WebDriverException(e);
9696
}

java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ public Object apply(WebDriver driver) {
15091509
Object value = ((JavascriptExecutor) driver).executeScript(javaScript);
15101510

15111511
if (value instanceof List) {
1512-
return ((List) value).isEmpty() ? null : value;
1512+
return ((List<?>) value).isEmpty() ? null : value;
15131513
}
15141514
if (value instanceof String) {
15151515
return ((String) value).isEmpty() ? null : value;

java/client/test/org/openqa/selenium/remote/ErrorHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public void testShouldStillIncludeScreenshotEvenIfServerSideExceptionsAreDisable
441441

442442
@Test
443443
public void testStatusCodesRaisedBackToStatusMatches() {
444-
Map<Integer, Class> exceptions = new HashMap<>();
444+
Map<Integer, Class<?>> exceptions = new HashMap<>();
445445
exceptions.put(ErrorCodes.NO_SUCH_SESSION, NoSuchSessionException.class);
446446
exceptions.put(ErrorCodes.NO_SUCH_ELEMENT, NoSuchElementException.class);
447447
exceptions.put(ErrorCodes.NO_SUCH_FRAME, NoSuchFrameException.class);
@@ -470,7 +470,7 @@ public void testStatusCodesRaisedBackToStatusMatches() {
470470
exceptions.put(ErrorCodes.INVALID_XPATH_SELECTOR_RETURN_TYPER, InvalidSelectorException.class);
471471

472472
Set<String> collectedFailures = new HashSet<>();
473-
for (Map.Entry<Integer, Class> exception : exceptions.entrySet()) {
473+
for (Map.Entry<Integer, Class<?>> exception : exceptions.entrySet()) {
474474
try {
475475
handler.throwIfResponseFailed(createResponse(exception.getKey()), 123);
476476
fail("Should have thrown an Exception");

java/client/test/org/openqa/selenium/remote/ProtocolHandshakeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ public void shouldNotIncludeNonProtocolExtensionKeys() throws IOException {
221221

222222
Map<?, ?> capabilities = (Map<?, ?>) rawCaps;
223223

224-
Map<?, ?> always = (Map<?, ?>) capabilities.get("alwaysMatch");
224+
Map<String, ?> always = (Map<String, ?>) capabilities.get("alwaysMatch");
225225
List<Map<?, ?>> first = (List<Map<?, ?>>) capabilities.get("firstMatch");
226226

227227
// We don't care where they are, but we want to see "se:option" and not "option"
228-
Set<String> keys = new HashSet(always.keySet());
228+
Set<String> keys = new HashSet<>(always.keySet());
229229
keys.addAll(first.stream()
230230
.map(Map::keySet)
231231
.flatMap(Collection::stream)

0 commit comments

Comments
 (0)