Skip to content

Commit

Permalink
Optional is useless in parameters, it does not prevent NPE, just make…
Browse files Browse the repository at this point in the history
…s harder to call methods.
  • Loading branch information
barancev committed Mar 30, 2017
1 parent cd0b8b7 commit 4c38c03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions java/client/src/org/openqa/selenium/interactions/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.IntConsumer;
import java.util.logging.Logger;
Expand All @@ -56,10 +55,8 @@ public class Actions {

// W3C
private final Map<InputSource, Sequence> sequences = new HashMap<>();
private final PointerInput defaultMouse = new PointerInput(
MOUSE,
Optional.of("default mouse"));
private final KeyInput defaultKeyboard = new KeyInput(Optional.of("default keyboard"));
private final PointerInput defaultMouse = new PointerInput(MOUSE, "default mouse");
private final KeyInput defaultKeyboard = new KeyInput("default keyboard");

// JSON-wire protocol
private final Keyboard jsonKeyboard;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class KeyInput implements InputSource, Encodable {

private final String name;

public KeyInput(Optional<String> name) {
this.name = name.orElse(UUID.randomUUID().toString());
public KeyInput(String name) {
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class PointerInput implements InputSource, Encodable {
private final Kind kind;
private final String name;

public PointerInput(Kind kind, Optional<String> name) {
public PointerInput(Kind kind, String name) {
this.kind = Preconditions.checkNotNull(kind, "Must set kind of pointer device");
this.name = name.orElse(UUID.randomUUID().toString());
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
}

@Override
Expand Down

0 comments on commit 4c38c03

Please sign in to comment.