Skip to content

Commit bd434fb

Browse files
mk868diemol
andauthored
[java] JSpecify annotations for ScriptKey and UnpinnedScriptKey (#16483)
Co-authored-by: Diego Molina <[email protected]>
1 parent c1160a5 commit bd434fb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

java/src/org/openqa/selenium/ScriptKey.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
package org.openqa.selenium;
1919

2020
import java.util.Objects;
21+
import org.jspecify.annotations.NullMarked;
22+
import org.jspecify.annotations.Nullable;
2123
import org.openqa.selenium.internal.Require;
2224

25+
@NullMarked
2326
public class ScriptKey {
2427

2528
private final String identifier;
@@ -33,7 +36,7 @@ public String getIdentifier() {
3336
}
3437

3538
@Override
36-
public boolean equals(Object o) {
39+
public boolean equals(@Nullable Object o) {
3740
if (!(o instanceof ScriptKey)) {
3841
return false;
3942
}

java/src/org/openqa/selenium/UnpinnedScriptKey.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
import java.util.Set;
2424
import java.util.UUID;
2525
import java.util.WeakHashMap;
26+
import org.jspecify.annotations.NullMarked;
27+
import org.jspecify.annotations.Nullable;
2628

29+
@NullMarked
2730
public class UnpinnedScriptKey extends ScriptKey {
2831

2932
private static final WeakHashMap<JavascriptExecutor, Set<UnpinnedScriptKey>> pinnedScripts =
3033
new WeakHashMap<>();
3134
private final String script;
32-
private String scriptId;
35+
private @Nullable String scriptId;
3336
private final String scriptHandle;
3437

3538
static UnpinnedScriptKey pin(JavascriptExecutor executor, String script) {
@@ -61,11 +64,11 @@ public UnpinnedScriptKey(String script) {
6164
this.script = script;
6265
}
6366

64-
public void setScriptId(String id) {
67+
public void setScriptId(@Nullable String id) {
6568
this.scriptId = id;
6669
}
6770

68-
public String getScriptId() {
71+
public @Nullable String getScriptId() {
6972
return this.scriptId;
7073
}
7174

@@ -91,7 +94,7 @@ public String removalScript() {
9194
}
9295

9396
@Override
94-
public boolean equals(Object o) {
97+
public boolean equals(@Nullable Object o) {
9598
if (this == o) {
9699
return true;
97100
}

0 commit comments

Comments
 (0)