[java] JSpecify annotations for immutable models and enums #14395
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Description
In this PR I'm adding nullness annotations for classes
Dimension
Keys
Point
Rectangle
UsernameAndPassword
Dimension
equals
accepts null argument -> marked with@Nullable
Keys
getKeyFromUnicode
can return null value -> return type marked with@Nullable
Point
equals
accepts null argument -> marked with@Nullable
Rectangle
equals
accepts null argument -> marked with@Nullable
UsernameAndPassword
No null values
Motivation and Context
The JSpecify nullness annotations will give developers better exposure to potential problems with their code to avoid NullPointerExceptions.
Related issue: #14291
Types of changes
Checklist
PR Type
enhancement
Description
@NullMarked
annotations to several classes and enums to improve nullness handling.equals
methods inDimension
,Point
, andRectangle
classes to accept@Nullable
parameters.getKeyFromUnicode
method inKeys
enum to return@Nullable
.NullPointerExceptions
.Changes walkthrough 📝
Dimension.java
Add nullness annotations to Dimension class
java/src/org/openqa/selenium/Dimension.java
@NullMarked
annotation to theDimension
class.equals
method to accept@Nullable
parameter.Keys.java
Add nullness annotations to Keys enum
java/src/org/openqa/selenium/Keys.java
@NullMarked
annotation to theKeys
enum.getKeyFromUnicode
method to return@Nullable
.Point.java
Add nullness annotations to Point class
java/src/org/openqa/selenium/Point.java
@NullMarked
annotation to thePoint
class.equals
method to accept@Nullable
parameter.Rectangle.java
Add nullness annotations to Rectangle class
java/src/org/openqa/selenium/Rectangle.java
@NullMarked
annotation to theRectangle
class.equals
method to accept@Nullable
parameter.UsernameAndPassword.java
Add nullness annotations to UsernameAndPassword class
java/src/org/openqa/selenium/UsernameAndPassword.java
@NullMarked
annotation to theUsernameAndPassword
class.