Skip to content

Commit 07f128f

Browse files
committed
[FEAT] Restore factory method and optimize record implementation
- Added the static factory method `of(String username, String password)` to maintain compatibility with existing Selenium code that relies on it. - Optimized the constructor by using a compact form, ensuring `username` and `password` are non-null without explicitly redefining fields. - Removed redundant `username()` and `password()` methods, as they are automatically generated by the `record` structure. - Improved code clarity, maintainability, and adherence to Java's record best practices.
1 parent 6cccaa0 commit 07f128f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

java/src/org/openqa/selenium/UsernameAndPassword.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
/** A combination of username and password to use when authenticating a browser with a website. */
2323
public record UsernameAndPassword(String username, String password) implements Credentials {
2424

25-
public UsernameAndPassword(String username, String password) {
26-
this.username = Require.nonNull("User name", username);
27-
this.password = Require.nonNull("Password", password);
25+
public UsernameAndPassword {
26+
username = Require.nonNull("User name", username);
27+
password = Require.nonNull("Password", password);
28+
}
29+
30+
public static UsernameAndPassword of(String username, String password) {
31+
return new UsernameAndPassword(username, password);
2832
}
2933
}

0 commit comments

Comments
 (0)