Skip to content

Commit e7324ef

Browse files
authored
[java] Reduce redundant toString() calls (#13932)
* removed unnecessary semicolons * removed redundant access modifier for interface member * removed redundant toString() calls for id in RedisBackedSessionMap * removed redundant toString() call in DragAndDropTest * removed redundant toString() calls * applying formatting
1 parent 2aa0f5a commit e7324ef

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

java/src/org/openqa/selenium/bidi/network/FetchError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private FetchError(BaseParameters baseParameters, String errorText) {
4141

4242
public static FetchError fromJsonMap(Map<String, Object> jsonMap) {
4343
try (StringReader baseParameterReader = new StringReader(JSON.toJson(jsonMap));
44-
JsonInput baseParamsInput = JSON.newInput(baseParameterReader); ) {
44+
JsonInput baseParamsInput = JSON.newInput(baseParameterReader)) {
4545
String errorText = JSON.toJson(jsonMap.get("errorText"));
4646
return new FetchError(BaseParameters.fromJson(baseParamsInput), errorText);
4747
}

java/src/org/openqa/selenium/bidi/script/EvaluateResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface EvaluateResult {
2222

2323
String getRealmId();
2424

25-
public enum Type {
25+
enum Type {
2626
SUCCESS("success"),
2727
EXCEPTION("exception");
2828

java/src/org/openqa/selenium/bidi/script/SerializationOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class SerializationOptions {
2626
public enum IncludeShadowTree {
2727
NONE,
2828
OPEN,
29-
ALL;
29+
ALL
3030
}
3131

3232
private Optional<Long> maxDomDepth = Optional.empty();

java/src/org/openqa/selenium/grid/sessionmap/redis/RedisBackedSessionMap.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,25 @@ public boolean isReady() {
316316
private String uriKey(SessionId id) {
317317
Require.nonNull("Session ID", id);
318318

319-
return "session:" + id.toString() + ":uri";
319+
return "session:" + id + ":uri";
320320
}
321321

322322
private String capabilitiesKey(SessionId id) {
323323
Require.nonNull("Session ID", id);
324324

325-
return "session:" + id.toString() + ":capabilities";
325+
return "session:" + id + ":capabilities";
326326
}
327327

328328
private String startKey(SessionId id) {
329329
Require.nonNull("Session ID", id);
330330

331-
return "session:" + id.toString() + ":start";
331+
return "session:" + id + ":start";
332332
}
333333

334334
private String stereotypeKey(SessionId id) {
335335
Require.nonNull("Session ID", id);
336336

337-
return "session:" + id.toString() + ":stereotype";
337+
return "session:" + id + ":stereotype";
338338
}
339339

340340
private void setCommonSpanAttributes(Span span) {

java/src/org/openqa/selenium/json/JsonInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public Number nextNumber() {
246246
}
247247
return number.longValue();
248248
} catch (NumberFormatException e) {
249-
throw new JsonException("Unable to parse to a number: " + builder.toString() + ". " + input);
249+
throw new JsonException("Unable to parse to a number: " + builder + ". " + input);
250250
}
251251
}
252252

java/src/org/openqa/selenium/remote/ErrorCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ public int getHttpStatusCode(Throwable throwable) {
144144

145145
public WebDriverException decode(Map<String, Object> response) {
146146
if (!(response.get("value") instanceof Map)) {
147-
throw new IllegalArgumentException("Unable to find mapping for " + response.toString());
147+
throw new IllegalArgumentException("Unable to find mapping for " + response);
148148
}
149149

150150
Map<?, ?> value = (Map<?, ?>) response.get("value");
151151
if (!(value.get("error") instanceof String)) {
152-
throw new IllegalArgumentException("Unable to find mapping for " + response.toString());
152+
throw new IllegalArgumentException("Unable to find mapping for " + response);
153153
}
154154

155155
String error = (String) value.get("error");

java/src/org/openqa/selenium/support/pagefactory/internal/LocatingElementHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Object invoke(Object object, Method method, Object[] objects) throws Thro
3838
element = locator.findElement();
3939
} catch (NoSuchElementException e) {
4040
if ("toString".equals(method.getName())) {
41-
return "Proxy element for: " + locator.toString();
41+
return "Proxy element for: " + locator;
4242
}
4343
throw e;
4444
}

java/test/org/openqa/selenium/ProxySettingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void canConfigureProxyThroughPACFile() throws URISyntaxException, Interru
9494
.join(
9595
"function FindProxyForURL(url, host) {",
9696
" return 'PROXY " + getHostAndPort(helloServer) + "';",
97-
"}")); ) {
97+
"}"))) {
9898

9999
Proxy proxy = new Proxy();
100100
proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");
@@ -132,7 +132,7 @@ public void canUsePACThatOnlyProxiesCertainHosts()
132132
" return 'PROXY " + getHostAndPort(goodbyeServer) + "';",
133133
" }",
134134
" return 'DIRECT';",
135-
"}")); ) {
135+
"}"))) {
136136

137137
Proxy proxy = new Proxy();
138138
proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");

java/test/org/openqa/selenium/interactions/DragAndDropTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static void sleep(int ms) {
4343
try {
4444
Thread.sleep(ms);
4545
} catch (InterruptedException e) {
46-
throw new RuntimeException("Interrupted: " + e.toString());
46+
throw new RuntimeException("Interrupted: " + e);
4747
}
4848
}
4949

java/test/org/openqa/selenium/javascript/TestFileLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static String getTestFilePath(Path baseDir, Path testFile) {
101101
testFile
102102
.toAbsolutePath()
103103
.toString()
104-
.replace(baseDir.toAbsolutePath().toString() + File.separator, "")
104+
.replace(baseDir.toAbsolutePath() + File.separator, "")
105105
.replace(File.separator, "/");
106106
if (path.endsWith(".js")) {
107107
path = "common/generated/" + path;

0 commit comments

Comments
 (0)