Skip to content

Commit 7806c7d

Browse files
committed
Fix KeyEvent
1 parent f0aad8a commit 7806c7d

File tree

1 file changed

+3
-2
lines changed
  • src/main/java/io/appium/java_client/android/nativekey

1 file changed

+3
-2
lines changed

src/main/java/io/appium/java_client/android/nativekey/KeyEvent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Collections;
2020
import java.util.HashMap;
2121
import java.util.Map;
22+
import java.util.Optional;
2223

2324
import static java.util.Optional.ofNullable;
2425

@@ -83,8 +84,8 @@ public KeyEvent withFlag(KeyEventFlag keyEventFlag) {
8384
*/
8485
public Map<String, Object> build() {
8586
var map = new HashMap<String, Object>();
86-
ofNullable(this.keyCode).map(x -> map.put("keycode", x)).orElseThrow(() -> new IllegalStateException(
87-
"The key code must be set"));
87+
Integer keyCode = ofNullable(this.keyCode).orElseThrow(() -> new IllegalStateException("The key code must be set"));
88+
map.put("keycode", keyCode);
8889
ofNullable(this.metaState).ifPresent(x -> map.put("metastate", x));
8990
ofNullable(this.flags).ifPresent(x -> map.put("flags", x));
9091
return Collections.unmodifiableMap(map);

0 commit comments

Comments
 (0)