Skip to content

Commit 6cccaa0

Browse files
committed
Refactor UsernameAndPassword to use Java record
Refactored the `UsernameAndPassword` class to a `record`, simplifying the implementation and ensuring immutability. Removed the redundant `of` method and `Supplier<Credentials>` usage, as they are no longer needed with the record structure.
1 parent e4d3db3 commit 6cccaa0

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,13 @@
1717

1818
package org.openqa.selenium;
1919

20-
import java.util.function.Supplier;
2120
import org.openqa.selenium.internal.Require;
2221

2322
/** A combination of username and password to use when authenticating a browser with a website. */
24-
public class UsernameAndPassword implements Credentials {
25-
26-
private final String username;
27-
private final String password;
23+
public record UsernameAndPassword(String username, String password) implements Credentials {
2824

2925
public UsernameAndPassword(String username, String password) {
3026
this.username = Require.nonNull("User name", username);
3127
this.password = Require.nonNull("Password", password);
3228
}
33-
34-
public static Supplier<Credentials> of(String username, String password) {
35-
Require.nonNull("User name", username);
36-
Require.nonNull("Password", password);
37-
38-
Credentials creds = new UsernameAndPassword(username, password);
39-
40-
return () -> creds;
41-
}
42-
43-
public String username() {
44-
return username;
45-
}
46-
47-
public String password() {
48-
return password;
49-
}
5029
}

0 commit comments

Comments
 (0)