Merge "Make getText() nullable and return null." into sc-dev

This commit is contained in:
Adam He
2021-05-13 20:52:48 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 15 deletions

View File

@@ -52900,7 +52900,7 @@ package android.view.translation {
public final class TranslationRequestValue implements android.os.Parcelable { public final class TranslationRequestValue implements android.os.Parcelable {
method public int describeContents(); method public int describeContents();
method @NonNull public static android.view.translation.TranslationRequestValue forText(@NonNull CharSequence); method @NonNull public static android.view.translation.TranslationRequestValue forText(@NonNull CharSequence);
method @NonNull public CharSequence getText(); method @Nullable public CharSequence getText();
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationRequestValue> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.TranslationRequestValue> CREATOR;
} }

View File

@@ -46,22 +46,17 @@ public final class TranslationRequestValue implements Parcelable {
} }
/** /**
* @return the text value as a {@link CharSequence}. * @return the text value as a {@link CharSequence} or {@code null} if the value is not of type
* * text.
* @throws IllegalStateException if the format of this {@link TranslationRequestValue} is not a
* text value.
*/ */
@NonNull @Nullable
public CharSequence getText() { public CharSequence getText() {
if (mText == null) {
throw new IllegalStateException("Value is not of type text");
}
return mText; return mText;
} }
// Code below generated by codegen v1.0.22. // Code below generated by codegen v1.0.23.
// //
// DO NOT MODIFY! // DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code // CHECKSTYLE:OFF Generated code
@@ -111,7 +106,7 @@ public final class TranslationRequestValue implements Parcelable {
TranslationRequestValue that = (TranslationRequestValue) o; TranslationRequestValue that = (TranslationRequestValue) o;
//noinspection PointlessBooleanExpression //noinspection PointlessBooleanExpression
return true return true
&& java.util.Objects.equals(mText, that.mText); && Objects.equals(mText, that.mText);
} }
@Override @Override
@@ -121,7 +116,7 @@ public final class TranslationRequestValue implements Parcelable {
// int fieldNameHashCode() { ... } // int fieldNameHashCode() { ... }
int _hash = 1; int _hash = 1;
_hash = 31 * _hash + java.util.Objects.hashCode(mText); _hash = 31 * _hash + Objects.hashCode(mText);
return _hash; return _hash;
} }
@@ -171,10 +166,10 @@ public final class TranslationRequestValue implements Parcelable {
}; };
@DataClass.Generated( @DataClass.Generated(
time = 1613687761635L, time = 1620259864154L,
codegenVersion = "1.0.22", codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/view/translation/TranslationRequestValue.java", sourceFile = "frameworks/base/core/java/android/view/translation/TranslationRequestValue.java",
inputSignatures = "private final @android.annotation.Nullable java.lang.CharSequence mText\npublic static @android.annotation.NonNull android.view.translation.TranslationRequestValue forText(java.lang.CharSequence)\npublic @android.annotation.NonNull java.lang.CharSequence getText()\nclass TranslationRequestValue extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genToString=true, genEqualsHashCode=true)") inputSignatures = "private final @android.annotation.Nullable java.lang.CharSequence mText\npublic static @android.annotation.NonNull android.view.translation.TranslationRequestValue forText(java.lang.CharSequence)\npublic @android.annotation.Nullable java.lang.CharSequence getText()\nclass TranslationRequestValue extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genToString=true, genEqualsHashCode=true)")
@Deprecated @Deprecated
private void __metadata() {} private void __metadata() {}