diff options
| author | 2020-01-10 17:17:30 +0000 | |
|---|---|---|
| committer | 2020-01-10 17:17:30 +0000 | |
| commit | 5bb34c7861a5929a50a69ecff70ca15ef722db41 (patch) | |
| tree | 137275c5c850f3cfcf638f13cc397e6c0b1b1a43 | |
| parent | ae6dd8d2536aa1c979949d48a3bc712099c006a2 (diff) | |
| parent | 1e62d2dd40949b7938d67dc3345ef406ddf5550e (diff) | |
Merge "Deprecate checkNotNull in favor of Objects.requireNonNull()." am: 7b511f0dd8 am: 1e62d2dd40
Change-Id: I9493491cecb3c2308d961e167c276204587a7ce6
| -rw-r--r-- | core/java/com/android/internal/util/Preconditions.java | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/core/java/com/android/internal/util/Preconditions.java b/core/java/com/android/internal/util/Preconditions.java index 3fff5c233890..994a01c023d8 100644 --- a/core/java/com/android/internal/util/Preconditions.java +++ b/core/java/com/android/internal/util/Preconditions.java @@ -126,7 +126,9 @@ public class Preconditions { * @param reference an object reference * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null + * @deprecated - use {@link java.util.Objects.requireNonNull} instead. */ + @Deprecated @UnsupportedAppUsage public static @NonNull <T> T checkNotNull(final T reference) { if (reference == null) { @@ -144,7 +146,9 @@ public class Preconditions { * be converted to a string using {@link String#valueOf(Object)} * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null + * @deprecated - use {@link java.util.Objects.requireNonNull} instead. */ + @Deprecated @UnsupportedAppUsage public static @NonNull <T> T checkNotNull(final T reference, final Object errorMessage) { if (reference == null) { @@ -154,26 +158,6 @@ public class Preconditions { } /** - * Ensures that an object reference passed as a parameter to the calling - * method is not null. - * - * @param reference an object reference - * @param messageTemplate a printf-style message template to use if the check fails; will - * be converted to a string using {@link String#format(String, Object...)} - * @param messageArgs arguments for {@code messageTemplate} - * @return the non-null reference that was validated - * @throws NullPointerException if {@code reference} is null - */ - public static @NonNull <T> T checkNotNull(final T reference, - final String messageTemplate, - final Object... messageArgs) { - if (reference == null) { - throw new NullPointerException(String.format(messageTemplate, messageArgs)); - } - return reference; - } - - /** * Ensures the truth of an expression involving the state of the calling * instance, but not involving any parameters to the calling method. * |