Skip to content

Commit d4a247c

Browse files
authored
Merge branch 'trunk' into java_cookie
2 parents 654b79c + 6141259 commit d4a247c

File tree

14 files changed

+62
-20
lines changed

14 files changed

+62
-20
lines changed

java/src/org/openqa/selenium/PageLoadStrategy.java

Lines changed: 5 additions & 1 deletion
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)) {

java/src/org/openqa/selenium/UnexpectedAlertBehaviour.java

Lines changed: 5 additions & 1 deletion
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)) {

java/src/org/openqa/selenium/WindowType.java

Lines changed: 5 additions & 1 deletion
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)) {

java/src/org/openqa/selenium/interactions/Actions.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.util.Objects;
3131
import java.util.Set;
3232
import java.util.function.IntConsumer;
33+
import org.jspecify.annotations.NullMarked;
34+
import org.jspecify.annotations.Nullable;
3335
import org.openqa.selenium.WebDriver;
3436
import org.openqa.selenium.WebElement;
3537
import org.openqa.selenium.interactions.PointerInput.Origin;
@@ -44,16 +46,17 @@
4446
*
4547
* <p>Call {@link #perform()} at the end of the method chain to actually perform the actions.
4648
*/
49+
@NullMarked
4750
public class Actions {
4851

4952
private final WebDriver driver;
5053

5154
// W3C
5255
private final Map<InputSource, Sequence> sequences = new HashMap<>();
5356

54-
private PointerInput activePointer;
55-
private KeyInput activeKeyboard;
56-
private WheelInput activeWheel;
57+
private @Nullable PointerInput activePointer;
58+
private @Nullable KeyInput activeKeyboard;
59+
private @Nullable WheelInput activeWheel;
5760
private Duration actionDuration;
5861

5962
public Actions(WebDriver driver) {
@@ -537,21 +540,21 @@ public KeyInput getActiveKeyboard() {
537540
if (this.activeKeyboard == null) {
538541
setActiveKeyboard("default keyboard");
539542
}
540-
return this.activeKeyboard;
543+
return Require.nonNull("ActiveKeyboard", this.activeKeyboard);
541544
}
542545

543546
public PointerInput getActivePointer() {
544547
if (this.activePointer == null) {
545548
setActivePointer(PointerInput.Kind.MOUSE, "default mouse");
546549
}
547-
return this.activePointer;
550+
return Require.nonNull("ActivePointer", this.activePointer);
548551
}
549552

550553
public WheelInput getActiveWheel() {
551554
if (this.activeWheel == null) {
552555
setActiveWheel("default wheel");
553556
}
554-
return this.activeWheel;
557+
return Require.nonNull("ActiveWheel", this.activeWheel);
555558
}
556559

557560
public Duration getActionDuration() {

java/src/org/openqa/selenium/interactions/Pause.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import java.time.Duration;
2323
import java.util.HashMap;
2424
import java.util.Map;
25+
import org.jspecify.annotations.NullMarked;
2526

2627
/** Indicates that a given {@link InputSource} should pause for a given duration. */
28+
@NullMarked
2729
public class Pause extends Interaction implements Encodable {
2830

2931
private final Duration duration;

java/src/org/openqa/selenium/interactions/Sequence.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.LinkedList;
2323
import java.util.List;
2424
import java.util.Map;
25+
import org.jspecify.annotations.NullMarked;
2526

2627
/**
2728
* A sequence of action objects for a given {@link InputSource} for use with the W3C <a
@@ -30,6 +31,7 @@
3031
* Interaction}s, with the first item in each sequence being executed at the same time, then the
3132
* second, and so on, until all interactions in all sequences have been executed.
3233
*/
34+
@NullMarked
3335
public class Sequence implements Encodable {
3436

3537
private final List<Encodable> actions = new LinkedList<>();

java/src/org/openqa/selenium/interactions/WheelInput.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.util.Map;
2525
import java.util.Optional;
2626
import java.util.UUID;
27+
import org.jspecify.annotations.NullMarked;
28+
import org.jspecify.annotations.Nullable;
2729
import org.openqa.selenium.Point;
2830
import org.openqa.selenium.WebElement;
2931
import org.openqa.selenium.WrapsElement;
@@ -33,11 +35,12 @@
3335
* Models a <a href="https://www.w3.org/TR/webdriver/#dfn-wheel-input-source">wheel input
3436
* source</a>.
3537
*/
38+
@NullMarked
3639
public class WheelInput implements InputSource, Encodable {
3740

3841
private final String name;
3942

40-
public WheelInput(String name) {
43+
public WheelInput(@Nullable String name) {
4144
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
4245
}
4346

java/src/org/openqa/selenium/logging/LogEntries.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
import java.util.Iterator;
2424
import java.util.List;
2525
import java.util.stream.StreamSupport;
26+
import org.jspecify.annotations.NullMarked;
2627
import org.openqa.selenium.Beta;
2728

2829
/**
2930
* Represent a pool of {@link LogEntry}. This class also provides filtering mechanisms based on
3031
* levels.
3132
*/
3233
@Beta
34+
@NullMarked
3335
public class LogEntries implements Iterable<LogEntry> {
3436

3537
private final List<LogEntry> entries;

java/src/org/openqa/selenium/logging/LogEntry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import java.util.HashMap;
2323
import java.util.Map;
2424
import java.util.logging.Level;
25+
import org.jspecify.annotations.NullMarked;
2526

2627
/** Represents a single log statement. */
28+
@NullMarked
2729
public class LogEntry {
2830

2931
private final Level level;

java/src/org/openqa/selenium/logging/LogLevelMapping.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@
2020
import java.util.Collections;
2121
import java.util.HashMap;
2222
import java.util.Map;
23+
import java.util.Optional;
2324
import java.util.logging.Level;
25+
import org.jspecify.annotations.NullMarked;
26+
import org.jspecify.annotations.Nullable;
2427

28+
@NullMarked
2529
public class LogLevelMapping {
2630

2731
/** WebDriver log level DEBUG which is mapped to Level.FINE. */
2832
private static final String DEBUG = "DEBUG";
2933

34+
// Default the log level to info.
35+
private static final Level DEFAULT_LEVEL = Level.INFO;
36+
3037
private static final Map<Integer, Level> levelMap;
3138

3239
static {
@@ -70,15 +77,15 @@ public static String getName(Level level) {
7077
return normalized == Level.FINE ? DEBUG : normalized.getName();
7178
}
7279

73-
public static Level toLevel(String logLevelName) {
80+
public static Level toLevel(@Nullable String logLevelName) {
7481
if (logLevelName == null || logLevelName.isEmpty()) {
75-
// Default the log level to info.
76-
return Level.INFO;
82+
return DEFAULT_LEVEL;
7783
}
7884

7985
if (logLevelName.equals(DEBUG)) {
8086
return Level.FINE;
8187
}
82-
return levelMap.get(Level.parse(logLevelName).intValue());
88+
return Optional.ofNullable(levelMap.get(Level.parse(logLevelName).intValue()))
89+
.orElse(DEFAULT_LEVEL);
8390
}
8491
}

0 commit comments

Comments
 (0)