Skip to content

Commit 418ab13

Browse files
mk868VietND96
authored andcommitted
[java] Add nullness for enums (SeleniumHQ#15105)
Co-authored-by: Viet Nguyen Duc <[email protected]>
1 parent 1c7d010 commit 418ab13

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Diff for: java/src/org/openqa/selenium/PageLoadStrategy.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
package org.openqa.selenium;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
22+
23+
@NullMarked
2024
public enum PageLoadStrategy {
2125
NONE("none"),
2226
EAGER("eager"),
@@ -33,7 +37,7 @@ public String toString() {
3337
return String.valueOf(text);
3438
}
3539

36-
public static PageLoadStrategy fromString(String text) {
40+
public static @Nullable PageLoadStrategy fromString(@Nullable String text) {
3741
if (text != null) {
3842
for (PageLoadStrategy b : PageLoadStrategy.values()) {
3943
if (text.equalsIgnoreCase(b.text)) {

Diff for: java/src/org/openqa/selenium/UnexpectedAlertBehaviour.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
package org.openqa.selenium;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
22+
23+
@NullMarked
2024
public enum UnexpectedAlertBehaviour {
2125
ACCEPT("accept"),
2226
DISMISS("dismiss"),
@@ -35,7 +39,7 @@ public String toString() {
3539
return String.valueOf(text);
3640
}
3741

38-
public static UnexpectedAlertBehaviour fromString(String text) {
42+
public static @Nullable UnexpectedAlertBehaviour fromString(@Nullable String text) {
3943
if (text != null) {
4044
for (UnexpectedAlertBehaviour b : UnexpectedAlertBehaviour.values()) {
4145
if (text.equalsIgnoreCase(b.text)) {

Diff for: java/src/org/openqa/selenium/WindowType.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
package org.openqa.selenium;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
import org.jspecify.annotations.Nullable;
22+
2023
/** Represents the type of new browser window that may be created. */
24+
@NullMarked
2125
public enum WindowType {
2226
WINDOW("window"),
2327
TAB("tab"),
@@ -34,7 +38,7 @@ public String toString() {
3438
return String.valueOf(text);
3539
}
3640

37-
public static WindowType fromString(String text) {
41+
public static @Nullable WindowType fromString(@Nullable String text) {
3842
if (text != null) {
3943
for (WindowType b : WindowType.values()) {
4044
if (text.equalsIgnoreCase(b.text)) {

0 commit comments

Comments
 (0)