Skip to content

[java] Add nullness for enums #15105

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

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading