Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull
Bug: 126528330
Test: Treehugger
Exempt-From-Owner-Approval: Global refactoring.
Change-Id: Idf0949bd58a73bef2b5f3ecb6b99b2be2d1059c4
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 3b6a009..f6aaa6f 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -139,6 +139,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* Helper class used by TextView to handle editable text views.
@@ -7062,11 +7063,11 @@
private final List<ResolveInfo> mSupportedActivities = new ArrayList<>();
private ProcessTextIntentActionsHandler(Editor editor) {
- mEditor = Preconditions.checkNotNull(editor);
- mTextView = Preconditions.checkNotNull(mEditor.mTextView);
- mContext = Preconditions.checkNotNull(mTextView.getContext());
- mPackageManager = Preconditions.checkNotNull(mContext.getPackageManager());
- mPackageName = Preconditions.checkNotNull(mContext.getPackageName());
+ mEditor = Objects.requireNonNull(editor);
+ mTextView = Objects.requireNonNull(mEditor.mTextView);
+ mContext = Objects.requireNonNull(mTextView.getContext());
+ mPackageManager = Objects.requireNonNull(mContext.getPackageManager());
+ mPackageName = Objects.requireNonNull(mContext.getPackageName());
}
/**
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index f58b6d1..2924dd9 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -62,6 +62,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
/**
* Android magnifier widget. Can be used by any view which is attached to a window.
@@ -1154,7 +1155,7 @@
* @param view the view this magnifier is attached to
*/
public Builder(@NonNull View view) {
- mView = Preconditions.checkNotNull(view);
+ mView = Objects.requireNonNull(view);
applyDefaults();
}
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index d0f8093..4ef3f61 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -87,7 +87,7 @@
private final SmartSelectSprite mSmartSelectSprite;
SelectionActionModeHelper(@NonNull Editor editor) {
- mEditor = Preconditions.checkNotNull(editor);
+ mEditor = Objects.requireNonNull(editor);
mTextView = mEditor.getTextView();
mTextClassificationHelper = new TextClassificationHelper(
mTextView.getContext(),
@@ -500,7 +500,7 @@
private final LogAbandonRunnable mDelayedLogAbandon = new LogAbandonRunnable();
SelectionTracker(TextView textView) {
- mTextView = Preconditions.checkNotNull(textView);
+ mTextView = Objects.requireNonNull(textView);
mLogger = new SelectionMetricsLogger(textView);
}
@@ -703,7 +703,7 @@
private String mText;
SelectionMetricsLogger(TextView textView) {
- Preconditions.checkNotNull(textView);
+ Objects.requireNonNull(textView);
mEditTextLogger = textView.isTextEditable();
mTokenIterator = SelectionSessionLogger.getTokenIterator(textView.getTextLocale());
}
@@ -714,7 +714,7 @@
CharSequence text, int index,
@InvocationMethod int invocationMethod) {
try {
- Preconditions.checkNotNull(text);
+ Objects.requireNonNull(text);
Preconditions.checkArgumentInRange(index, 0, text.length(), "index");
if (mText == null || !mText.contentEquals(text)) {
mText = text.toString();
@@ -972,11 +972,11 @@
@NonNull Consumer<SelectionResult> selectionResultCallback,
@NonNull Supplier<SelectionResult> timeOutResultSupplier) {
super(textView != null ? textView.getHandler() : null);
- mTextView = Preconditions.checkNotNull(textView);
+ mTextView = Objects.requireNonNull(textView);
mTimeOutDuration = timeOut;
- mSelectionResultSupplier = Preconditions.checkNotNull(selectionResultSupplier);
- mSelectionResultCallback = Preconditions.checkNotNull(selectionResultCallback);
- mTimeOutResultSupplier = Preconditions.checkNotNull(timeOutResultSupplier);
+ mSelectionResultSupplier = Objects.requireNonNull(selectionResultSupplier);
+ mSelectionResultCallback = Objects.requireNonNull(selectionResultCallback);
+ mTimeOutResultSupplier = Objects.requireNonNull(timeOutResultSupplier);
// Make a copy of the original text.
mOriginalText = getText(mTextView).toString();
}
@@ -1051,14 +1051,14 @@
TextClassificationHelper(Context context, Supplier<TextClassifier> textClassifier,
CharSequence text, int selectionStart, int selectionEnd, LocaleList locales) {
init(textClassifier, text, selectionStart, selectionEnd, locales);
- mContext = Preconditions.checkNotNull(context);
+ mContext = Objects.requireNonNull(context);
}
@UiThread
public void init(Supplier<TextClassifier> textClassifier, CharSequence text,
int selectionStart, int selectionEnd, LocaleList locales) {
- mTextClassifier = Preconditions.checkNotNull(textClassifier);
- mText = Preconditions.checkNotNull(text).toString();
+ mTextClassifier = Objects.requireNonNull(textClassifier);
+ mText = Objects.requireNonNull(text).toString();
mLastClassificationText = null; // invalidate.
Preconditions.checkArgument(selectionEnd > selectionStart);
mSelectionStart = selectionStart;
diff --git a/core/java/android/widget/SmartSelectSprite.java b/core/java/android/widget/SmartSelectSprite.java
index 9a84f69..dc472e1 100644
--- a/core/java/android/widget/SmartSelectSprite.java
+++ b/core/java/android/widget/SmartSelectSprite.java
@@ -38,13 +38,12 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import com.android.internal.util.Preconditions;
-
import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Objects;
/**
* A utility class for creating and animating the Smart Select animation.
@@ -75,7 +74,7 @@
private final int mTextSelectionLayout;
RectangleWithTextSelectionLayout(RectF rectangle, int textSelectionLayout) {
- mRectangle = Preconditions.checkNotNull(rectangle);
+ mRectangle = Objects.requireNonNull(rectangle);
mTextSelectionLayout = textSelectionLayout;
}
@@ -342,7 +341,7 @@
context,
android.R.interpolator.fast_out_linear_in);
mFillColor = highlightColor;
- mInvalidator = Preconditions.checkNotNull(invalidator);
+ mInvalidator = Objects.requireNonNull(invalidator);
}
/**