diff --git a/java/src/org/openqa/selenium/interactions/Encodable.java b/java/src/org/openqa/selenium/interactions/Encodable.java index f213dd67049f2..5e05325cca4b8 100644 --- a/java/src/org/openqa/selenium/interactions/Encodable.java +++ b/java/src/org/openqa/selenium/interactions/Encodable.java @@ -18,12 +18,14 @@ package org.openqa.selenium.interactions; import java.util.Map; +import org.jspecify.annotations.NullMarked; /** * This interface allows a custom {@link Interaction} to be JSON encoded for the W3C wire format. It * should not normally be exposed or used by user-facing APIs. Instead, these should traffic in the * {@link Interaction} interface. */ +@NullMarked public interface Encodable { Map encode(); } diff --git a/java/src/org/openqa/selenium/interactions/InputSource.java b/java/src/org/openqa/selenium/interactions/InputSource.java index a8187d1db422f..c7c9060e82c73 100644 --- a/java/src/org/openqa/selenium/interactions/InputSource.java +++ b/java/src/org/openqa/selenium/interactions/InputSource.java @@ -17,10 +17,13 @@ package org.openqa.selenium.interactions; +import org.jspecify.annotations.NullMarked; + /** * Models an input source as defined * and used by the W3C WebDriver spec. */ +@NullMarked public interface InputSource { SourceType getInputType(); diff --git a/java/src/org/openqa/selenium/interactions/KeyInput.java b/java/src/org/openqa/selenium/interactions/KeyInput.java index e3b73a87d57fc..c82c5800951b3 100644 --- a/java/src/org/openqa/selenium/interactions/KeyInput.java +++ b/java/src/org/openqa/selenium/interactions/KeyInput.java @@ -21,15 +21,18 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Models a key input source. */ +@NullMarked public class KeyInput implements InputSource, Encodable { private final String name; - public KeyInput(String name) { + public KeyInput(@Nullable String name) { this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString()); } diff --git a/java/src/org/openqa/selenium/interactions/PointerInput.java b/java/src/org/openqa/selenium/interactions/PointerInput.java index 7aeb708992cd6..d2343e352290e 100644 --- a/java/src/org/openqa/selenium/interactions/PointerInput.java +++ b/java/src/org/openqa/selenium/interactions/PointerInput.java @@ -24,6 +24,8 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; import org.openqa.selenium.WrapsElement; @@ -33,12 +35,13 @@ * Models a pointer input * source. */ +@NullMarked public class PointerInput implements InputSource, Encodable { private final Kind kind; private final String name; - public PointerInput(Kind kind, String name) { + public PointerInput(Kind kind, @Nullable String name) { this.kind = Require.nonNull("Kind of pointer device", kind); this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString()); } @@ -283,15 +286,15 @@ public static PointerEventProperties eventProperties() { } public static class PointerEventProperties implements Encodable { - private Float width = null; - private Float height = null; - private Float pressure = null; - private Float tangentialPressure = null; - private Integer tiltX = null; - private Integer tiltY = null; - private Integer twist = null; - private Float altitudeAngle = null; - private Float azimuthAngle = null; + private @Nullable Float width = null; + private @Nullable Float height = null; + private @Nullable Float pressure = null; + private @Nullable Float tangentialPressure = null; + private @Nullable Integer tiltX = null; + private @Nullable Integer tiltY = null; + private @Nullable Integer twist = null; + private @Nullable Float altitudeAngle = null; + private @Nullable Float azimuthAngle = null; public PointerEventProperties setWidth(float width) { Require.nonNull("width", width);