Skip to content

Commit dbe3f27

Browse files
authored
[java] Add nullness for interactions (#15095)
1 parent 9ef48bf commit dbe3f27

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

Diff for: java/src/org/openqa/selenium/interactions/Encodable.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
package org.openqa.selenium.interactions;
1919

2020
import java.util.Map;
21+
import org.jspecify.annotations.NullMarked;
2122

2223
/**
2324
* This interface allows a custom {@link Interaction} to be JSON encoded for the W3C wire format. It
2425
* should not normally be exposed or used by user-facing APIs. Instead, these should traffic in the
2526
* {@link Interaction} interface.
2627
*/
28+
@NullMarked
2729
public interface Encodable {
2830
Map<String, Object> encode();
2931
}

Diff for: java/src/org/openqa/selenium/interactions/InputSource.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
package org.openqa.selenium.interactions;
1919

20+
import org.jspecify.annotations.NullMarked;
21+
2022
/**
2123
* Models an <a href="https://www.w3.org/TR/webdriver/#dfn-input-source">input source</a> as defined
2224
* and used by the W3C WebDriver spec.
2325
*/
26+
@NullMarked
2427
public interface InputSource {
2528
SourceType getInputType();
2629

Diff for: java/src/org/openqa/selenium/interactions/KeyInput.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
import java.util.Map;
2222
import java.util.Optional;
2323
import java.util.UUID;
24+
import org.jspecify.annotations.NullMarked;
25+
import org.jspecify.annotations.Nullable;
2426

2527
/**
2628
* Models a <a href="https://www.w3.org/TR/webdriver/#dfn-key-input-source">key input source</a>.
2729
*/
30+
@NullMarked
2831
public class KeyInput implements InputSource, Encodable {
2932

3033
private final String name;
3134

32-
public KeyInput(String name) {
35+
public KeyInput(@Nullable String name) {
3336
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
3437
}
3538

Diff for: java/src/org/openqa/selenium/interactions/PointerInput.java

+13-10
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,12 +35,13 @@
3335
* Models a <a href="https://www.w3.org/TR/webdriver/#dfn-pointer-input-source">pointer input
3436
* source</a>.
3537
*/
38+
@NullMarked
3639
public class PointerInput implements InputSource, Encodable {
3740

3841
private final Kind kind;
3942
private final String name;
4043

41-
public PointerInput(Kind kind, String name) {
44+
public PointerInput(Kind kind, @Nullable String name) {
4245
this.kind = Require.nonNull("Kind of pointer device", kind);
4346
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
4447
}
@@ -283,15 +286,15 @@ public static PointerEventProperties eventProperties() {
283286
}
284287

285288
public static class PointerEventProperties implements Encodable {
286-
private Float width = null;
287-
private Float height = null;
288-
private Float pressure = null;
289-
private Float tangentialPressure = null;
290-
private Integer tiltX = null;
291-
private Integer tiltY = null;
292-
private Integer twist = null;
293-
private Float altitudeAngle = null;
294-
private Float azimuthAngle = null;
289+
private @Nullable Float width = null;
290+
private @Nullable Float height = null;
291+
private @Nullable Float pressure = null;
292+
private @Nullable Float tangentialPressure = null;
293+
private @Nullable Integer tiltX = null;
294+
private @Nullable Integer tiltY = null;
295+
private @Nullable Integer twist = null;
296+
private @Nullable Float altitudeAngle = null;
297+
private @Nullable Float azimuthAngle = null;
295298

296299
public PointerEventProperties setWidth(float width) {
297300
Require.nonNull("width", width);

0 commit comments

Comments
 (0)