-
-
Notifications
You must be signed in to change notification settings - Fork 759
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
fix: usage of Optional.orElseThrow after Map.put #2145
Changes from 1 commit
7806c7d
dfdd24f
31a9279
5ecd06a
9a19742
c55d0a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static java.util.Optional.ofNullable; | ||
|
||
|
@@ -83,8 +84,8 @@ public KeyEvent withFlag(KeyEventFlag keyEventFlag) { | |
*/ | ||
public Map<String, Object> build() { | ||
var map = new HashMap<String, Object>(); | ||
ofNullable(this.keyCode).map(x -> map.put("keycode", x)).orElseThrow(() -> new IllegalStateException( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @valfirst Could there be other places in the source like this one? I assume the issue may have been added during the recent refactoring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is a regression issue, I've found 2 more similar occurrences, I'll open PR soon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks. Lets address them all and publish a patch asap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mykola-mokhnach I believe I fixed them in my last commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've already addressed |
||
"The key code must be set")); | ||
Integer keyCode = ofNullable(this.keyCode).orElseThrow(() -> new IllegalStateException("The key code must be set")); | ||
map.put("keycode", keyCode); | ||
ofNullable(this.metaState).ifPresent(x -> map.put("metastate", x)); | ||
ofNullable(this.flags).ifPresent(x -> map.put("flags", x)); | ||
return Collections.unmodifiableMap(map); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need for this import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed