-
-
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
Changes from 4 commits
6cccaa0
07f128f
1e57f88
9779f68
f4f1b4e
360f785
2ceac19
a6583b9
0904700
8b53174
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 |
|---|---|---|
|
|
@@ -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); | ||
| } | ||
| } | ||
| } | ||
|
||
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