-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] Refactored the UsernameAndPassword class to a record
#15360
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6cccaa0
Refactor UsernameAndPassword to use Java record
manuelsblanco 07f128f
[FEAT] Restore factory method and optimize record implementation
manuelsblanco 1e57f88
Merge branch 'trunk' into recordClass
manuelsblanco 9779f68
Merge branch 'trunk' into recordClass
manuelsblanco f4f1b4e
[FEAT] Newline added by request from @Delta456
manuelsblanco 360f785
Merge branch 'trunk' into recordClass
VietND96 2ceac19
Merge branch 'trunk' into recordClass
manuelsblanco a6583b9
Merge branch 'trunk' into recordClass
manuelsblanco 0904700
Merge branch 'trunk' into recordClass
manuelsblanco 8b53174
Merge branch 'trunk' into recordClass
pujagani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,36 +17,19 @@ | |
|
|
||
| package org.openqa.selenium; | ||
|
|
||
| import java.util.function.Supplier; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.openqa.selenium.internal.Require; | ||
|
|
||
| /** A combination of username and password to use when authenticating a browser with a website. */ | ||
| @NullMarked | ||
| public class UsernameAndPassword implements Credentials { | ||
| public record UsernameAndPassword(String username, String password) implements Credentials { | ||
|
|
||
| private final String username; | ||
| private final String password; | ||
|
|
||
| public UsernameAndPassword(String username, String password) { | ||
| this.username = Require.nonNull("User name", username); | ||
| this.password = Require.nonNull("Password", password); | ||
| } | ||
|
|
||
| public static Supplier<Credentials> of(String username, String password) { | ||
| Require.nonNull("User name", username); | ||
| Require.nonNull("Password", password); | ||
|
|
||
| Credentials creds = new UsernameAndPassword(username, password); | ||
|
|
||
| return () -> creds; | ||
| } | ||
|
|
||
| public String username() { | ||
| return username; | ||
| public UsernameAndPassword { | ||
| username = Require.nonNull("User name", username); | ||
| password = Require.nonNull("Password", password); | ||
| } | ||
|
|
||
| public String password() { | ||
| return password; | ||
| public static UsernameAndPassword of(String username, String password) { | ||
|
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. This is a breaking change. It is changing the function return type. |
||
| return new UsernameAndPassword(username, password); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please, note that this method is used by Selenium users, for example:
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.
@mk868 New commit with the new code added. Thanks