2323import java .util .Map ;
2424import java .util .Objects ;
2525import java .util .regex .Pattern ;
26+ import org .jspecify .annotations .NullMarked ;
27+ import org .jspecify .annotations .Nullable ;
2628import org .openqa .selenium .internal .Require ;
2729
2830/**
4042 * }
4143 * </code></pre>
4244 */
45+ @ NullMarked
4346public abstract class By {
4447 /**
4548 * @param id The value of the "id" attribute to search for.
@@ -158,7 +161,7 @@ protected JavascriptExecutor getJavascriptExecutor(SearchContext context) {
158161 }
159162
160163 @ Override
161- public boolean equals (Object o ) {
164+ public boolean equals (@ Nullable Object o ) {
162165 if (!(o instanceof By )) {
163166 return false ;
164167 }
@@ -341,9 +344,9 @@ public interface Remotable {
341344
342345 class Parameters {
343346 private final String using ;
344- private final Object value ;
347+ private final @ Nullable Object value ;
345348
346- public Parameters (String using , Object value ) {
349+ public Parameters (String using , @ Nullable Object value ) {
347350 this .using = Require .nonNull ("Search mechanism" , using );
348351 // There may be subclasses where the value is optional. Allow for this.
349352 this .value = value ;
@@ -353,7 +356,7 @@ public String using() {
353356 return using ;
354357 }
355358
356- public Object value () {
359+ public @ Nullable Object value () {
357360 return value ;
358361 }
359362
@@ -363,7 +366,7 @@ public String toString() {
363366 }
364367
365368 @ Override
366- public boolean equals (Object o ) {
369+ public boolean equals (@ Nullable Object o ) {
367370 if (!(o instanceof Parameters )) {
368371 return false ;
369372 }
@@ -376,8 +379,8 @@ public int hashCode() {
376379 return Objects .hash (using , value );
377380 }
378381
379- private Map <String , Object > toJson () {
380- Map <String , Object > params = new HashMap <>();
382+ private Map <String , @ Nullable Object > toJson () {
383+ Map <String , @ Nullable Object > params = new HashMap <>();
381384 params .put ("using" , using );
382385 params .put ("value" , value );
383386 return Collections .unmodifiableMap (params );
@@ -409,7 +412,7 @@ public final Parameters getRemoteParameters() {
409412 return params ;
410413 }
411414
412- protected final Map <String , Object > toJson () {
415+ protected final Map <String , @ Nullable Object > toJson () {
413416 return getRemoteParameters ().toJson ();
414417 }
415418 }
@@ -440,7 +443,7 @@ public final Parameters getRemoteParameters() {
440443 return remoteParams ;
441444 }
442445
443- protected final Map <String , Object > toJson () {
446+ protected final Map <String , @ Nullable Object > toJson () {
444447 return fallback .toJson ();
445448 }
446449
0 commit comments