Skip to content

Commit 8923748

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Make c.g.c.base.Objects methods delegate to j.u.Objects.
This _would_ prepare for adding `@InlineMe` except that I don't expect that to work well when both the "before" and "after" try to import a class named "`Objects`." Still, this change at least establishes the a migration from our methods to the JDK's is safe. RELNOTES=n/a PiperOrigin-RevId: 778491389
1 parent a8bec9c commit 8923748

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

android/guava/src/com/google/common/base/Objects.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private Objects() {}
4949
* java.util.Objects#equals} instead.
5050
*/
5151
public static boolean equal(@Nullable Object a, @Nullable Object b) {
52-
return a == b || (a != null && a.equals(b));
52+
return java.util.Objects.equals(a, b);
5353
}
5454

5555
/**
@@ -73,7 +73,8 @@ public static boolean equal(@Nullable Object a, @Nullable Object b) {
7373
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated; use {@link
7474
* java.util.Objects#hash} instead.
7575
*/
76+
@SuppressWarnings("nullness") // https://github.com/jspecify/jdk/pull/127
7677
public static int hashCode(@Nullable Object @Nullable ... objects) {
77-
return Arrays.hashCode(objects);
78+
return java.util.Objects.hash(objects);
7879
}
7980
}

guava/src/com/google/common/base/Objects.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private Objects() {}
4949
* java.util.Objects#equals} instead.
5050
*/
5151
public static boolean equal(@Nullable Object a, @Nullable Object b) {
52-
return a == b || (a != null && a.equals(b));
52+
return java.util.Objects.equals(a, b);
5353
}
5454

5555
/**
@@ -73,7 +73,8 @@ public static boolean equal(@Nullable Object a, @Nullable Object b) {
7373
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated; use {@link
7474
* java.util.Objects#hash} instead.
7575
*/
76+
@SuppressWarnings("nullness") // https://github.com/jspecify/jdk/pull/127
7677
public static int hashCode(@Nullable Object @Nullable ... objects) {
77-
return Arrays.hashCode(objects);
78+
return java.util.Objects.hash(objects);
7879
}
7980
}

0 commit comments

Comments
 (0)