- 
          
 - 
                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 ChromiumDriverconstructor.java/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java: Replaced lambda expressions with method references increatemethod and simplifiedifcondition to useisEmpty()instead of!isPresent(). [1] [2]java/src/org/openqa/selenium/firefox/FirefoxDriver.java: Replaced lambda expression with method reference inprivate FirefoxDriverconstructor.java/src/org/openqa/selenium/remote/RemoteWebDriver.java: Replaced lambda expression with method reference inaddCredentialmethod.Test code simplification:
java/test/org/openqa/selenium/NoSuchShadowRootTest.java: Simplified exception assertion by replacing lambda expression with method reference ingetNoSuchShadowRoottest method.java/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java: Simplified exception assertion by replacing lambda expression with method reference inprotocolVersionThrowsConfigExceptiontest method.java/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java: Simplified exception assertion by replacing lambda expression with method reference inexternalUriFailsForNonUriStringstest 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 constructorjava/src/org/openqa/selenium/chromium/ChromiumDriver.java
ChromiumDriverconstructor.
SeleniumCdpConnection.java
Refactor SeleniumCdpConnection with method references and simplifiedconditionsjava/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java
createmethod.isEmpty().FirefoxDriver.java
Use method reference in FirefoxDriver constructorjava/src/org/openqa/selenium/firefox/FirefoxDriver.java
FirefoxDriverconstructor.
RemoteWebDriver.java
Refactor addCredential method with method referencejava/src/org/openqa/selenium/remote/RemoteWebDriver.java
addCredentialmethod.
NoSuchShadowRootTest.java
Use method reference in NoSuchShadowRootTest assertionjava/test/org/openqa/selenium/NoSuchShadowRootTest.java
RelayOptionsTest.java
Use method reference in RelayOptionsTest assertionjava/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java
BaseServerOptionsTest.java
Use method reference in BaseServerOptionsTest assertionjava/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java