Skip to content

Commit 3dfe243

Browse files
artlomakovalfirst
andauthored
fix: Fix building of Android key event parameters (#2145)
Co-authored-by: Valery Yatsynovich <[email protected]>
1 parent bc39a23 commit 3dfe243

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ public KeyEvent withFlag(KeyEventFlag keyEventFlag) {
8383
*/
8484
public Map<String, Object> build() {
8585
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"));
86+
ofNullable(this.keyCode).ifPresentOrElse(x -> map.put("keycode", x), () -> {
87+
throw new IllegalStateException("The key code must be set");
88+
});
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)