-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java]Replace lambdas with method references #14857
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 lambdas with method references #14857
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Thank you! @iampopovich
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
This pull request includes several refactorings to improve code readability and consistency across multiple files, primarily by replacing lambda expressions with method references and simplifying conditional checks.
Code readability improvements:
java/src/org/openqa/selenium/chromium/ChromiumDriver.java
: Replaced lambda expression with method reference inprotected ChromiumDriver
constructor.java/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java
: Replaced lambda expressions with method references increate
method and simplifiedif
condition to useisEmpty()
instead of!isPresent()
. [1] [2]java/src/org/openqa/selenium/firefox/FirefoxDriver.java
: Replaced lambda expression with method reference inprivate FirefoxDriver
constructor.java/src/org/openqa/selenium/remote/RemoteWebDriver.java
: Replaced lambda expression with method reference inaddCredential
method.Test code simplification:
java/test/org/openqa/selenium/NoSuchShadowRootTest.java
: Simplified exception assertion by replacing lambda expression with method reference ingetNoSuchShadowRoot
test method.java/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java
: Simplified exception assertion by replacing lambda expression with method reference inprotocolVersionThrowsConfigException
test method.java/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java
: Simplified exception assertion by replacing lambda expression with method reference inexternalUriFailsForNonUriStrings
test method.Motivation and Context
While often it could be a matter of taste, method references are more clear and readable compared to lambdas.
Types of changes
Checklist
PR Type
enhancement, tests
Description
isEmpty()
instead of!isPresent()
.Changes walkthrough 📝
ChromiumDriver.java
Use method reference in ChromiumDriver constructor
java/src/org/openqa/selenium/chromium/ChromiumDriver.java
ChromiumDriver
constructor.
SeleniumCdpConnection.java
Refactor SeleniumCdpConnection with method references and simplified
conditions
java/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java
create
method.isEmpty()
.FirefoxDriver.java
Use method reference in FirefoxDriver constructor
java/src/org/openqa/selenium/firefox/FirefoxDriver.java
FirefoxDriver
constructor.
RemoteWebDriver.java
Refactor addCredential method with method reference
java/src/org/openqa/selenium/remote/RemoteWebDriver.java
addCredential
method.
NoSuchShadowRootTest.java
Use method reference in NoSuchShadowRootTest assertion
java/test/org/openqa/selenium/NoSuchShadowRootTest.java
RelayOptionsTest.java
Use method reference in RelayOptionsTest assertion
java/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java
BaseServerOptionsTest.java
Use method reference in BaseServerOptionsTest assertion
java/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java