Skip to content

Commit

Permalink
[java] Add nullness for enums (#15105)
Browse files Browse the repository at this point in the history
Co-authored-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
mk868 and VietND96 authored Jan 20, 2025
1 parent 4461033 commit 3c16d81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion java/src/org/openqa/selenium/PageLoadStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

@NullMarked
public enum PageLoadStrategy {
NONE("none"),
EAGER("eager"),
Expand All @@ -33,7 +37,7 @@ public String toString() {
return String.valueOf(text);
}

public static PageLoadStrategy fromString(String text) {
public static @Nullable PageLoadStrategy fromString(@Nullable String text) {
if (text != null) {
for (PageLoadStrategy b : PageLoadStrategy.values()) {
if (text.equalsIgnoreCase(b.text)) {
Expand Down
6 changes: 5 additions & 1 deletion java/src/org/openqa/selenium/UnexpectedAlertBehaviour.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

@NullMarked
public enum UnexpectedAlertBehaviour {
ACCEPT("accept"),
DISMISS("dismiss"),
Expand All @@ -35,7 +39,7 @@ public String toString() {
return String.valueOf(text);
}

public static UnexpectedAlertBehaviour fromString(String text) {
public static @Nullable UnexpectedAlertBehaviour fromString(@Nullable String text) {
if (text != null) {
for (UnexpectedAlertBehaviour b : UnexpectedAlertBehaviour.values()) {
if (text.equalsIgnoreCase(b.text)) {
Expand Down
6 changes: 5 additions & 1 deletion java/src/org/openqa/selenium/WindowType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Represents the type of new browser window that may be created. */
@NullMarked
public enum WindowType {
WINDOW("window"),
TAB("tab"),
Expand All @@ -34,7 +38,7 @@ public String toString() {
return String.valueOf(text);
}

public static WindowType fromString(String text) {
public static @Nullable WindowType fromString(@Nullable String text) {
if (text != null) {
for (WindowType b : WindowType.values()) {
if (text.equalsIgnoreCase(b.text)) {
Expand Down

0 comments on commit 3c16d81

Please sign in to comment.