Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Replace anonymous types with lambdas #15043

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions java/src/org/openqa/selenium/chromium/AddHasCdp.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,15 @@ public Class<HasCdp> getDescribedInterface() {

@Override
public HasCdp getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return new HasCdp() {
@Override
public Map<String, Object> executeCdpCommand(
String commandName, Map<String, Object> parameters) {
Require.nonNull("Command name", commandName);
Require.nonNull("Parameters", parameters);
return (commandName, parameters) -> {
Require.nonNull("Command name", commandName);
Require.nonNull("Parameters", parameters);

Map<String, Object> toReturn =
(Map<String, Object>)
executeMethod.execute(
EXECUTE_CDP, Map.of("cmd", commandName, "params", parameters));
Map<String, Object> toReturn =
(Map<String, Object>)
executeMethod.execute(EXECUTE_CDP, Map.of("cmd", commandName, "params", parameters));

return Map.copyOf(toReturn);
}
return Map.copyOf(toReturn);
};
}
}
10 changes: 3 additions & 7 deletions java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@ public Class<HasLaunchApp> getDescribedInterface() {

@Override
public HasLaunchApp getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return new HasLaunchApp() {
@Override
public void launchApp(String id) {
Require.nonNull("id of Chromium App", id);

executeMethod.execute(LAUNCH_APP, Map.of("id", id));
}
return id -> {
Require.nonNull("id of Chromium App", id);
executeMethod.execute(LAUNCH_APP, Map.of("id", id));
};
}
}
14 changes: 5 additions & 9 deletions java/src/org/openqa/selenium/chromium/AddHasPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ public Class<HasPermissions> getDescribedInterface() {

@Override
public HasPermissions getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return new HasPermissions() {
@Override
public void setPermission(String name, String value) {
Require.nonNull("Permission name", name);
Require.nonNull("Permission value", value);

executeMethod.execute(
SET_PERMISSION, Map.of("descriptor", Map.of("name", name), "state", value));
}
return (name, value) -> {
Require.nonNull("Permission name", name);
Require.nonNull("Permission value", value);
executeMethod.execute(
SET_PERMISSION, Map.of("descriptor", Map.of("name", name), "state", value));
};
}
}
7 changes: 1 addition & 6 deletions java/src/org/openqa/selenium/safari/AddHasDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public Class<HasDebugger> getDescribedInterface() {

@Override
public HasDebugger getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return new HasDebugger() {
@Override
public void attachDebugger() {
executeMethod.execute(ATTACH_DEBUGGER, null);
}
};
return () -> executeMethod.execute(ATTACH_DEBUGGER, null);
}
}