Skip to content

Commit

Permalink
Document why EqualsTester.addEqualityGroup has a @Nullable parame…
Browse files Browse the repository at this point in the history
…ter.

RELNOTES=n/a
PiperOrigin-RevId: 578260904
  • Loading branch information
eamonnmcmanus authored and Google Java Core Libraries committed Oct 31, 2023
1 parent 609f029 commit 9b8035d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ public EqualsTester() {
/**
* Adds {@code equalityGroup} with objects that are supposed to be equal to each other and not
* equal to any other equality groups added to this tester.
*
* <p>The {@code @Nullable} annotations on the {@code equalityGroup} parameter imply that the
* objects, and the array itself, can be null. That is for programmer convenience, when the
* objects come from factory methods that are themselves {@code @Nullable}. In reality neither the
* array nor its contents can be null, but it is not useful to force the use of {@code
* requireNonNull} or the like just to assert that.
*
* <p>{@code EqualsTester} will always check that every object it is given returns false from
* {@code equals(null)}, so it is neither useful nor allowed to include a null value in any
* equality group.
*/
@CanIgnoreReturnValue
public EqualsTester addEqualityGroup(@Nullable Object @Nullable ... equalityGroup) {
Expand Down
10 changes: 10 additions & 0 deletions guava-testlib/src/com/google/common/testing/EqualsTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ public EqualsTester() {
/**
* Adds {@code equalityGroup} with objects that are supposed to be equal to each other and not
* equal to any other equality groups added to this tester.
*
* <p>The {@code @Nullable} annotations on the {@code equalityGroup} parameter imply that the
* objects, and the array itself, can be null. That is for programmer convenience, when the
* objects come from factory methods that are themselves {@code @Nullable}. In reality neither the
* array nor its contents can be null, but it is not useful to force the use of {@code
* requireNonNull} or the like just to assert that.
*
* <p>{@code EqualsTester} will always check that every object it is given returns false from
* {@code equals(null)}, so it is neither useful nor allowed to include a null value in any
* equality group.
*/
@CanIgnoreReturnValue
public EqualsTester addEqualityGroup(@Nullable Object @Nullable ... equalityGroup) {
Expand Down

0 comments on commit 9b8035d

Please sign in to comment.