From 84bf25d6d3bcb52ed15bd21403dd4d52f3dce34a Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 24 Feb 2021 11:57:46 -0800 Subject: [PATCH] Accept generic in SparseArray contentEquals Also updates the JavaDoc. Bug: 181100924 Test: atest android.util.cts.SparseArrayTest Change-Id: I3704b2519d10e20d02437037c7f92f5d2ed90dcd --- core/api/current.txt | 2 +- core/java/android/util/SparseArray.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 5b639ff0b00f6..494ea115494f0 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -46300,7 +46300,7 @@ package android.util { method public void clear(); method public android.util.SparseArray clone(); method public boolean contains(int); - method public boolean contentEquals(@Nullable android.util.SparseArray); + method public boolean contentEquals(@Nullable android.util.SparseArray); method public int contentHashCode(); method public void delete(int); method public E get(int); diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java index 6718e93f908c4..05c8617294dab 100644 --- a/core/java/android/util/SparseArray.java +++ b/core/java/android/util/SparseArray.java @@ -510,10 +510,12 @@ public class SparseArray implements Cloneable { } /** + * Compares the contents of this {@link SparseArray} to the specified {@link SparseArray}. + * * For backwards compatibility reasons, {@link Object#equals(Object)} cannot be implemented, * so this serves as a manually invoked alternative. */ - public boolean contentEquals(@Nullable SparseArray other) { + public boolean contentEquals(@Nullable SparseArray other) { if (other == null) { return false; } @@ -534,6 +536,9 @@ public class SparseArray implements Cloneable { } /** + * Returns a hash code value for the contents of this {@link SparseArray}, combining the + * {@link Objects#hashCode(Object)} result of all its keys and values. + * * For backwards compatibility, {@link Object#hashCode()} cannot be implemented, so this serves * as a manually invoked alternative. */