TextClassification.text is nullable

Removes the @NonNull requirement on TextClassification.text.
e.g. TextClassifier.NO_OP doesn't classify text and thus returns
TextClassification.EMPTY which doesn't set TextClassification.text.
This is ideal as we need not make copies of this object when NO_OP
was performed.

Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest
bit FrameworksCoreTests:android.widget.TextViewActivityTest
bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: I0b3ac5bf0027cbd67ba40d1110f1100280c8c3a2
This commit is contained in:
Abodunrinwa Toki
2017-07-12 19:38:54 +01:00
parent 3c3acf8bf1
commit d44286f942

View File

@@ -50,11 +50,11 @@ public final class TextClassification {
private int mLogType;
private TextClassification(
@NonNull String text,
Drawable icon,
String label,
Intent intent,
OnClickListener onClickListener,
@Nullable String text,
@Nullable Drawable icon,
@Nullable String label,
@Nullable Intent intent,
@Nullable OnClickListener onClickListener,
@NonNull EntityConfidence<String> entityConfidence,
int logType) {
mText = text;
@@ -70,7 +70,7 @@ public final class TextClassification {
/**
* Gets the classified text.
*/
@NonNull
@Nullable
public String getText() {
return mText;
}
@@ -183,8 +183,8 @@ public final class TextClassification {
/**
* Sets the classified text.
*/
public Builder setText(@NonNull String text) {
mText = Preconditions.checkNotNull(text);
public Builder setText(@Nullable String text) {
mText = text;
return this;
}
@@ -197,7 +197,7 @@ public final class TextClassification {
*/
public Builder setEntityType(
@NonNull @EntityType String type,
@FloatRange(from = 0.0, to = 1.0)float confidenceScore) {
@FloatRange(from = 0.0, to = 1.0) float confidenceScore) {
mEntityConfidence.setEntityType(type, confidenceScore);
return this;
}