Skip to content

Commit

Permalink
fix IDEA warning "Declaration can have 'final' modifier"
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Oct 11, 2023
1 parent acbb602 commit be4a386
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 156 deletions.
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

/** A copy of java.awt.Point, to remove dependency on awt. */
public class Point {
public int x;
public int y;
final int x;
final int y;

public Point(int x, int y) {
this.x = x;
Expand Down
8 changes: 4 additions & 4 deletions java/src/org/openqa/selenium/Rectangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

public class Rectangle {

public int x;
public int y;
public int height;
public int width;
final int x;
final int y;
final int height;
final int width;

public Rectangle(int x, int y, int height, int width) {
this.x = x;
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/bidi/log/StackTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// href="https://w3c.github.io/webdriver-bidi/#types-script-StackTrace">https://w3c.github.io/webdriver-bidi/#types-script-StackTrace</a>
public class StackTrace {

List<StackFrame> callFrames;
private final List<StackFrame> callFrames;

public StackTrace(List<StackFrame> callFrames) {
this.callFrames = callFrames;
Expand Down
10 changes: 5 additions & 5 deletions java/src/org/openqa/selenium/devtools/CdpClientGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public BaseSpecParser(Map<String, BiConsumer<T, Object>> extraProcessors) {
}

private static class TypedSpec extends BaseSpec {
protected Domain domain;
protected final Domain domain;
protected IType type = new VoidType();

public TypedSpec(Domain domain) {
Expand Down Expand Up @@ -919,9 +919,9 @@ public String getMapper() {

private static class EnumType implements IType {

protected TypedSpec parent;
protected String name;
protected final List<String> values;
private final TypedSpec parent;
private String name;
private final List<String> values;

public EnumType(TypedSpec parent, String name, List<String> values) {
this.parent = parent;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ public String getTypeToken() {
}

public String getJavaType() {
return name;
return getName();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ private Addresses deriveAddresses(String host, String connection) {
}

private static class Addresses {
String bindTo;
String advertise;
boolean isIPv6;
final String bindTo;
final String advertise;
final boolean isIPv6;

Addresses(String bindTo, String advertise, boolean isIPv6) {
this.bindTo = bindTo;
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/grid/commands/InfoFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
public class InfoFlags {

@Parameter(description = "Topic to gather additional help on")
String topic = "help";
final String topic = "help";
}
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/interactions/PointerInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Interaction createPointerMove(Duration duration, Origin origin, int x, in
}

public Interaction createPointerMove(Duration duration, Origin origin, Point offset) {
return createPointerMove(duration, origin, offset.x, offset.y);
return createPointerMove(duration, origin, offset.getX(), offset.getY());
}

public Interaction createPointerMove(
Expand All @@ -82,7 +82,7 @@ public Interaction createPointerMove(

public Interaction createPointerMove(
Duration duration, Origin origin, Point offset, PointerEventProperties eventProperties) {
return createPointerMove(duration, origin, offset.x, offset.y, eventProperties);
return createPointerMove(duration, origin, offset.getX(), offset.getY(), eventProperties);
}

public Interaction createPointerDown(int button) {
Expand Down
6 changes: 3 additions & 3 deletions java/src/org/openqa/selenium/interactions/WheelInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Interaction createScroll(

public Interaction createScroll(
Point start, int deltaX, int deltaY, Duration duration, ScrollOrigin origin) {
return createScroll(start.x, start.y, deltaX, deltaY, duration, origin);
return createScroll(start.getX(), start.getY(), deltaX, deltaY, duration, origin);
}

@Override
Expand Down Expand Up @@ -116,8 +116,8 @@ public Map<String, Object> encode() {

public static final class ScrollOrigin {
private final Object originObject;
private int xOffset = 0;
private int yOffset = 0;
private final int xOffset;
private final int yOffset;

public Object asArg() {
Object arg = originObject;
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/DriverCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static CommandPayload IME_ACTIVATE_ENGINE(String engine) {

static CommandPayload SET_CURRENT_WINDOW_POSITION(Point targetPosition) {
return new CommandPayload(
SET_CURRENT_WINDOW_POSITION, ImmutableMap.of("x", targetPosition.x, "y", targetPosition.y));
SET_CURRENT_WINDOW_POSITION, ImmutableMap.of("x", targetPosition.getX(), "y", targetPosition.getY()));
}

static CommandPayload GET_CURRENT_WINDOW_POSITION() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs {
private LocalLogs logs = LocalLogs.getNullLogger();

private static class DefaultClientFactoryHolder {
static HttpClient.Factory defaultClientFactory = HttpClient.Factory.createDefault();
static final HttpClient.Factory defaultClientFactory = HttpClient.Factory.createDefault();
}

public static HttpClient.Factory getDefaultClientFactory() {
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/RemoteLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class RemoteLogs implements Logs {

private static final Logger LOG = Logger.getLogger(RemoteLogs.class.getName());

protected ExecuteMethod executeMethod;
private final ExecuteMethod executeMethod;

public static final String TYPE_KEY = "type";
private final LocalLogs localLogs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class DefaultFieldDecorator implements FieldDecorator {

protected ElementLocatorFactory factory;
protected final ElementLocatorFactory factory;

public DefaultFieldDecorator(ElementLocatorFactory factory) {
this.factory = factory;
Expand Down
15 changes: 5 additions & 10 deletions java/test/org/openqa/selenium/ReferrerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.google.common.net.HostAndPort;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.file.Files;
Expand Down Expand Up @@ -82,7 +81,7 @@
*/
class ReferrerTest {

@RegisterExtension static SeleniumExtension seleniumExtension = new SeleniumExtension();
@RegisterExtension static final SeleniumExtension seleniumExtension = new SeleniumExtension();

private static final String PAGE_1 = "/page1.html";
private static final String PAGE_2 = "/page2.html";
Expand Down Expand Up @@ -130,7 +129,7 @@ private WebDriver createDriver(String pacUrl) {
}

/**
* Tests navigation when all of the files are hosted on the same domain and the browser does not
* Tests navigation when all the files are hosted on the same domain and the browser does not
* have a proxy configured.
*/
@Test
Expand All @@ -148,7 +147,7 @@ void basicHistoryNavigationWithoutAProxy() {
}

/**
* Tests navigation when all of the files are hosted on the same domain and the browser is
* Tests navigation when all the files are hosted on the same domain and the browser is
* configured to use a proxy that permits direct access to that domain.
*/
@Test
Expand All @@ -169,11 +168,7 @@ void basicHistoryNavigationWithADirectProxy() {
}

private static String encode(String url) {
try {
return URLEncoder.encode(url, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("UTF-8 should always be supported!", e);
}
return URLEncoder.encode(url, UTF_8);
}

private void performNavigation(WebDriver driver, String firstUrl) {
Expand Down Expand Up @@ -238,7 +233,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
return new HttpResponse().setStatus(204);
}

// Don't record / requests so we can poll the server for availability in start().
// Don't record / requests, so we can poll the server for availability in start().
if (!"/".equals(req.getUri())) {
requests.add(new ExpectedRequest(req));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void shouldScrollFromViewportByGivenAmount() {
driver.get(
appServer.whereIs("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html"));
WebElement footer = driver.findElement(By.tagName("footer"));
int deltaY = footer.getRect().y;
int deltaY = footer.getRect().getY();

getBuilder(driver).scrollByAmount(0, deltaY).perform();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ public void setPointerEventProperties() {

Rectangle rect = pointerArea.getRect();

int centerX = (int) Math.floor(rect.width / 2 + rect.getX());
int centerY = (int) Math.floor(rect.height / 2 + rect.getY());
int centerX = (int) Math.floor(rect.getWidth() / 2 + rect.getX());
int centerY = (int) Math.floor(rect.getHeight() / 2 + rect.getY());
Assertions.assertThat(moveTo.get("button")).isEqualTo("-1");
Assertions.assertThat(moveTo.get("pageX")).isEqualTo("" + centerX);
Assertions.assertThat(moveTo.get("pageY")).isEqualTo("" + centerY);
Expand Down Expand Up @@ -452,7 +452,7 @@ private boolean fuzzyPositionMatching(int expectedX, int expectedY, String locat

private ExpectedCondition<Boolean> fuzzyMatchingOfCoordinates(
final WebElement element, final int x, final int y) {
return new ExpectedCondition<Boolean>() {
return new ExpectedCondition<>() {
@Override
public Boolean apply(WebDriver ignored) {
return fuzzyPositionMatching(x, y, element.getText());
Expand Down
2 changes: 1 addition & 1 deletion java/test/org/openqa/selenium/support/PageFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static class ChildPage extends PublicPage {

public static class ConstructedPage {

public WebDriver driver;
private final WebDriver driver;

public ConstructedPage(WebDriver driver) {
this.driver = driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class DecoratedAlertTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebDriver.TargetLocator originalSwitch;
Alert original;
Alert decorated;
final WebDriver originalDriver;
final WebDriver decoratedDriver;
final WebDriver.TargetLocator originalSwitch;
final Alert original;
final Alert decorated;

public Fixture() {
original = mock(Alert.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class DecoratedNavigationTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebDriver.Navigation original;
WebDriver.Navigation decorated;
private final WebDriver originalDriver;
private final WebDriver decoratedDriver;
private final WebDriver.Navigation original;
private final WebDriver.Navigation decorated;

public Fixture() {
original = mock(WebDriver.Navigation.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,13 @@ void logsNotDecorated() {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebDriver.Options original;
WebDriver.Options decorated;
private final WebDriver.Options original = mock();
private final WebDriver.Options decorated;

public Fixture() {
original = mock(WebDriver.Options.class);
originalDriver = mock(WebDriver.class);
WebDriver originalDriver = mock();
when(originalDriver.manage()).thenReturn(original);
decoratedDriver = new WebDriverDecorator<>().decorate(originalDriver);
WebDriver decoratedDriver = new WebDriverDecorator<>().decorate(originalDriver);
decorated = decoratedDriver.manage();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ class DecoratedSwitchToTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebDriver.TargetLocator original;
WebDriver.TargetLocator decorated;
private final WebDriver originalDriver = mock();
private final WebDriver.TargetLocator original = mock();
private final WebDriver.TargetLocator decorated;

public Fixture() {
original = mock(WebDriver.TargetLocator.class);
originalDriver = mock(WebDriver.class);
when(originalDriver.switchTo()).thenReturn(original);
decoratedDriver = new WebDriverDecorator<>().decorate(originalDriver);
WebDriver decoratedDriver = new WebDriverDecorator<>().decorate(originalDriver);
decorated = decoratedDriver.switchTo();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class DecoratedTimeoutsTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebDriver.Options originalOptions;
WebDriver.Timeouts original;
WebDriver.Timeouts decorated;
private final WebDriver originalDriver;
private final WebDriver decoratedDriver;
private final WebDriver.Options originalOptions;
private final WebDriver.Timeouts original;
private final WebDriver.Timeouts decorated;

public Fixture() {
original = mock(WebDriver.Timeouts.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class DecoratedVirtualAuthenticatorTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
VirtualAuthenticator original;
VirtualAuthenticator decorated;
private final WebDriver originalDriver;
private final WebDriver decoratedDriver;
private final VirtualAuthenticator original;
private final VirtualAuthenticator decorated;

public Fixture() {
original = mock(VirtualAuthenticator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class DecoratedWebDriverTest {

private static class Fixture {

WebDriver original;
VirtualAuthenticator originalAuth;
WebDriver decorated;
private final WebDriver original;
private final VirtualAuthenticator originalAuth;
private final WebDriver decorated;

public Fixture() {
original =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class DecoratedWebElementTest {

private static class Fixture {

WebDriver originalDriver;
WebDriver decoratedDriver;
WebElement original;
WebElement decorated;
private final WebDriver originalDriver;
private final WebDriver decoratedDriver;
private final WebElement original;
private final WebElement decorated;

public Fixture() {
original = mock(WebElement.class);
Expand Down
Loading

0 comments on commit be4a386

Please sign in to comment.