| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.translation; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Bundle; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
import com.android.internal.util.DataClass; |
| 26 |
|
| 27 |
import java.util.Objects; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true, |
| 33 |
genHiddenConstDefs = true) |
| 34 |
public final class TranslationResponseValue implements Parcelable { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public static final int STATUS_SUCCESS = 0; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static final int STATUS_ERROR = 1; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
public static final String EXTRA_DEFINITIONS = "android.view.translation.extra.DEFINITIONS"; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
private final @Status int mStatusCode; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
@Nullable |
| 85 |
private final CharSequence mText; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
@NonNull |
| 94 |
private final Bundle mExtras; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
@Nullable |
| 103 |
private final CharSequence mTransliteration; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
@NonNull |
| 109 |
public static TranslationResponseValue forError() { |
| 110 |
return new TranslationResponseValue(STATUS_ERROR, null, Bundle.EMPTY, null); |
| 111 |
} |
| 112 |
|
| 113 |
private static CharSequence defaultText() { |
| 114 |
return null; |
| 115 |
} |
| 116 |
|
| 117 |
private static Bundle defaultExtras() { |
| 118 |
return Bundle.EMPTY; |
| 119 |
} |
| 120 |
|
| 121 |
private boolean extrasEquals(Bundle other) { |
| 122 |
|
| 123 |
return Objects.equals(mExtras, other) || (mExtras.isEmpty() && other.isEmpty()); |
| 124 |
} |
| 125 |
|
| 126 |
private static CharSequence defaultTransliteration() { |
| 127 |
return null; |
| 128 |
} |
| 129 |
|
| 130 |
@DataClass.Suppress("setStatusCode") |
| 131 |
abstract static class BaseBuilder { |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
@android.annotation.IntDef(prefix = "STATUS_", value = { |
| 152 |
STATUS_SUCCESS, |
| 153 |
STATUS_ERROR |
| 154 |
}) |
| 155 |
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) |
| 156 |
@DataClass.Generated.Member |
| 157 |
public @interface Status {} |
| 158 |
|
| 159 |
|
| 160 |
@DataClass.Generated.Member |
| 161 |
public static String statusToString(@Status int value) { |
| 162 |
switch (value) { |
| 163 |
case STATUS_SUCCESS: |
| 164 |
return "STATUS_SUCCESS"; |
| 165 |
case STATUS_ERROR: |
| 166 |
return "STATUS_ERROR"; |
| 167 |
default: return Integer.toHexString(value); |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
@DataClass.Generated.Member |
| 172 |
TranslationResponseValue( |
| 173 |
@Status int statusCode, |
| 174 |
@Nullable CharSequence text, |
| 175 |
@NonNull Bundle extras, |
| 176 |
@Nullable CharSequence transliteration) { |
| 177 |
this.mStatusCode = statusCode; |
| 178 |
|
| 179 |
if (!(mStatusCode == STATUS_SUCCESS) |
| 180 |
&& !(mStatusCode == STATUS_ERROR)) { |
| 181 |
throw new java.lang.IllegalArgumentException( |
| 182 |
"statusCode was " + mStatusCode + " but must be one of: " |
| 183 |
+ "STATUS_SUCCESS(" + STATUS_SUCCESS + "), " |
| 184 |
+ "STATUS_ERROR(" + STATUS_ERROR + ")"); |
| 185 |
} |
| 186 |
|
| 187 |
this.mText = text; |
| 188 |
this.mExtras = extras; |
| 189 |
com.android.internal.util.AnnotationValidations.validate( |
| 190 |
NonNull.class, null, mExtras); |
| 191 |
this.mTransliteration = transliteration; |
| 192 |
|
| 193 |
|
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
@DataClass.Generated.Member |
| 203 |
public @Status int getStatusCode() { |
| 204 |
return mStatusCode; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
@DataClass.Generated.Member |
| 211 |
public @Nullable CharSequence getText() { |
| 212 |
return mText; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
@DataClass.Generated.Member |
| 222 |
public @NonNull Bundle getExtras() { |
| 223 |
return mExtras; |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
@DataClass.Generated.Member |
| 232 |
public @Nullable CharSequence getTransliteration() { |
| 233 |
return mTransliteration; |
| 234 |
} |
| 235 |
|
| 236 |
@Override |
| 237 |
@DataClass.Generated.Member |
| 238 |
public String toString() { |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
return "TranslationResponseValue { " + |
| 243 |
"statusCode = " + statusToString(mStatusCode) + ", " + |
| 244 |
"text = " + mText + ", " + |
| 245 |
"extras = " + mExtras + ", " + |
| 246 |
"transliteration = " + mTransliteration + |
| 247 |
" }"; |
| 248 |
} |
| 249 |
|
| 250 |
@Override |
| 251 |
@DataClass.Generated.Member |
| 252 |
public boolean equals(@Nullable Object o) { |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
if (this == o) return true; |
| 258 |
if (o == null || getClass() != o.getClass()) return false; |
| 259 |
@SuppressWarnings("unchecked") |
| 260 |
TranslationResponseValue that = (TranslationResponseValue) o; |
| 261 |
|
| 262 |
return true |
| 263 |
&& mStatusCode == that.mStatusCode |
| 264 |
&& Objects.equals(mText, that.mText) |
| 265 |
&& extrasEquals(that.mExtras) |
| 266 |
&& Objects.equals(mTransliteration, that.mTransliteration); |
| 267 |
} |
| 268 |
|
| 269 |
@Override |
| 270 |
@DataClass.Generated.Member |
| 271 |
public int hashCode() { |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
int _hash = 1; |
| 276 |
_hash = 31 * _hash + mStatusCode; |
| 277 |
_hash = 31 * _hash + Objects.hashCode(mText); |
| 278 |
_hash = 31 * _hash + Objects.hashCode(mExtras); |
| 279 |
_hash = 31 * _hash + Objects.hashCode(mTransliteration); |
| 280 |
return _hash; |
| 281 |
} |
| 282 |
|
| 283 |
@Override |
| 284 |
@DataClass.Generated.Member |
| 285 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
byte flg = 0; |
| 290 |
if (mText != null) flg |= 0x2; |
| 291 |
if (mTransliteration != null) flg |= 0x8; |
| 292 |
dest.writeByte(flg); |
| 293 |
dest.writeInt(mStatusCode); |
| 294 |
if (mText != null) dest.writeCharSequence(mText); |
| 295 |
dest.writeBundle(mExtras); |
| 296 |
if (mTransliteration != null) dest.writeCharSequence(mTransliteration); |
| 297 |
} |
| 298 |
|
| 299 |
@Override |
| 300 |
@DataClass.Generated.Member |
| 301 |
public int describeContents() { return 0; } |
| 302 |
|
| 303 |
|
| 304 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 305 |
@DataClass.Generated.Member |
| 306 |
TranslationResponseValue(@NonNull Parcel in) { |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
byte flg = in.readByte(); |
| 311 |
int statusCode = in.readInt(); |
| 312 |
CharSequence text = (flg & 0x2) == 0 ? null : (CharSequence) in.readCharSequence(); |
| 313 |
Bundle extras = in.readBundle(); |
| 314 |
CharSequence transliteration = (flg & 0x8) == 0 ? null : (CharSequence) in.readCharSequence(); |
| 315 |
|
| 316 |
this.mStatusCode = statusCode; |
| 317 |
|
| 318 |
if (!(mStatusCode == STATUS_SUCCESS) |
| 319 |
&& !(mStatusCode == STATUS_ERROR)) { |
| 320 |
throw new java.lang.IllegalArgumentException( |
| 321 |
"statusCode was " + mStatusCode + " but must be one of: " |
| 322 |
+ "STATUS_SUCCESS(" + STATUS_SUCCESS + "), " |
| 323 |
+ "STATUS_ERROR(" + STATUS_ERROR + ")"); |
| 324 |
} |
| 325 |
|
| 326 |
this.mText = text; |
| 327 |
this.mExtras = extras; |
| 328 |
com.android.internal.util.AnnotationValidations.validate( |
| 329 |
NonNull.class, null, mExtras); |
| 330 |
this.mTransliteration = transliteration; |
| 331 |
|
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
@DataClass.Generated.Member |
| 336 |
public static final @NonNull Parcelable.Creator<TranslationResponseValue> CREATOR |
| 337 |
= new Parcelable.Creator<TranslationResponseValue>() { |
| 338 |
@Override |
| 339 |
public TranslationResponseValue[] newArray(int size) { |
| 340 |
return new TranslationResponseValue[size]; |
| 341 |
} |
| 342 |
|
| 343 |
@Override |
| 344 |
public TranslationResponseValue createFromParcel(@NonNull Parcel in) { |
| 345 |
return new TranslationResponseValue(in); |
| 346 |
} |
| 347 |
}; |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
@SuppressWarnings("WeakerAccess") |
| 353 |
@DataClass.Generated.Member |
| 354 |
public static final class Builder extends BaseBuilder { |
| 355 |
|
| 356 |
private @Status int mStatusCode; |
| 357 |
private @Nullable CharSequence mText; |
| 358 |
private @NonNull Bundle mExtras; |
| 359 |
private @Nullable CharSequence mTransliteration; |
| 360 |
|
| 361 |
private long mBuilderFieldsSet = 0L; |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
public Builder( |
| 373 |
@Status int statusCode) { |
| 374 |
mStatusCode = statusCode; |
| 375 |
|
| 376 |
if (!(mStatusCode == STATUS_SUCCESS) |
| 377 |
&& !(mStatusCode == STATUS_ERROR)) { |
| 378 |
throw new java.lang.IllegalArgumentException( |
| 379 |
"statusCode was " + mStatusCode + " but must be one of: " |
| 380 |
+ "STATUS_SUCCESS(" + STATUS_SUCCESS + "), " |
| 381 |
+ "STATUS_ERROR(" + STATUS_ERROR + ")"); |
| 382 |
} |
| 383 |
|
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
@DataClass.Generated.Member |
| 390 |
public @NonNull Builder setText(@NonNull CharSequence value) { |
| 391 |
checkNotUsed(); |
| 392 |
mBuilderFieldsSet |= 0x2; |
| 393 |
mText = value; |
| 394 |
return this; |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
@DataClass.Generated.Member |
| 404 |
public @NonNull Builder setExtras(@NonNull Bundle value) { |
| 405 |
checkNotUsed(); |
| 406 |
mBuilderFieldsSet |= 0x4; |
| 407 |
mExtras = value; |
| 408 |
return this; |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
@DataClass.Generated.Member |
| 417 |
public @NonNull Builder setTransliteration(@NonNull CharSequence value) { |
| 418 |
checkNotUsed(); |
| 419 |
mBuilderFieldsSet |= 0x8; |
| 420 |
mTransliteration = value; |
| 421 |
return this; |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
public @NonNull TranslationResponseValue build() { |
| 426 |
checkNotUsed(); |
| 427 |
mBuilderFieldsSet |= 0x10; |
| 428 |
|
| 429 |
if ((mBuilderFieldsSet & 0x2) == 0) { |
| 430 |
mText = defaultText(); |
| 431 |
} |
| 432 |
if ((mBuilderFieldsSet & 0x4) == 0) { |
| 433 |
mExtras = defaultExtras(); |
| 434 |
} |
| 435 |
if ((mBuilderFieldsSet & 0x8) == 0) { |
| 436 |
mTransliteration = defaultTransliteration(); |
| 437 |
} |
| 438 |
TranslationResponseValue o = new TranslationResponseValue( |
| 439 |
mStatusCode, |
| 440 |
mText, |
| 441 |
mExtras, |
| 442 |
mTransliteration); |
| 443 |
return o; |
| 444 |
} |
| 445 |
|
| 446 |
private void checkNotUsed() { |
| 447 |
if ((mBuilderFieldsSet & 0x10) != 0) { |
| 448 |
throw new IllegalStateException( |
| 449 |
"This Builder should not be reused. Use a new Builder instance instead"); |
| 450 |
} |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
@DataClass.Generated( |
| 455 |
time = 1631057245846L, |
| 456 |
codegenVersion = "1.0.23", |
| 457 |
sourceFile = "frameworks/base/core/java/android/view/translation/TranslationResponseValue.java", |
| 458 |
inputSignatures = "public static final int STATUS_SUCCESS\npublic static final int STATUS_ERROR\npublic static final java.lang.String EXTRA_DEFINITIONS\nprivate final @android.view.translation.TranslationResponseValue.Status int mStatusCode\nprivate final @android.annotation.Nullable java.lang.CharSequence mText\nprivate final @android.annotation.NonNull android.os.Bundle mExtras\nprivate final @android.annotation.Nullable java.lang.CharSequence mTransliteration\npublic static @android.annotation.NonNull android.view.translation.TranslationResponseValue forError()\nprivate static java.lang.CharSequence defaultText()\nprivate static android.os.Bundle defaultExtras()\nprivate boolean extrasEquals(android.os.Bundle)\nprivate static java.lang.CharSequence defaultTransliteration()\nclass TranslationResponseValue extends java.lang.Object implements [android.os.Parcelable]\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true, genHiddenConstDefs=true)\nclass BaseBuilder extends java.lang.Object implements []") |
| 459 |
@Deprecated |
| 460 |
private void __metadata() {} |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
} |