| 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.annotation.SuppressLint; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
import android.util.ArrayMap; |
| 25 |
import android.view.autofill.AutofillId; |
| 26 |
|
| 27 |
import com.android.internal.util.DataClass; |
| 28 |
|
| 29 |
import java.util.Collections; |
| 30 |
import java.util.Map; |
| 31 |
import java.util.Objects; |
| 32 |
import java.util.Set; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true, genGetters = false) |
| 39 |
public final class ViewTranslationResponse implements Parcelable { |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
@NonNull |
| 45 |
private final AutofillId mAutofillId; |
| 46 |
|
| 47 |
@NonNull |
| 48 |
@DataClass.PluralOf("translationResponseValue") |
| 49 |
private final Map<String, TranslationResponseValue> mTranslationResponseValues; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
@NonNull |
| 58 |
public TranslationResponseValue getValue(@NonNull String key) { |
| 59 |
Objects.requireNonNull(key); |
| 60 |
if (!mTranslationResponseValues.containsKey(key)) { |
| 61 |
throw new IllegalArgumentException("Request does not contain value for key=" + key); |
| 62 |
} |
| 63 |
return mTranslationResponseValues.get(key); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
@NonNull |
| 71 |
public Set<String> getKeys() { |
| 72 |
return mTranslationResponseValues.keySet(); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
@NonNull |
| 80 |
public AutofillId getAutofillId() { |
| 81 |
return mAutofillId; |
| 82 |
} |
| 83 |
|
| 84 |
private static Map<String, TranslationResponseValue> defaultTranslationResponseValues() { |
| 85 |
return Collections.emptyMap(); |
| 86 |
} |
| 87 |
|
| 88 |
@DataClass.Suppress({"addTranslationResponseValue", "setAutofillId"}) |
| 89 |
abstract static class BaseBuilder { |
| 90 |
|
| 91 |
abstract Builder setTranslationResponseValues(Map<String, TranslationResponseValue> value); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
@SuppressLint("MissingGetterMatchingBuilder") |
| 101 |
public Builder setValue(String key, |
| 102 |
TranslationResponseValue value) { |
| 103 |
final Builder builder = (Builder) this; |
| 104 |
if (builder.mTranslationResponseValues == null) { |
| 105 |
setTranslationResponseValues(new ArrayMap<>()); |
| 106 |
} |
| 107 |
builder.mTranslationResponseValues.put(key, value); |
| 108 |
return builder; |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
@DataClass.Generated.Member |
| 128 |
ViewTranslationResponse( |
| 129 |
@NonNull AutofillId autofillId, |
| 130 |
@NonNull Map<String,TranslationResponseValue> translationResponseValues) { |
| 131 |
this.mAutofillId = autofillId; |
| 132 |
com.android.internal.util.AnnotationValidations.validate( |
| 133 |
NonNull.class, null, mAutofillId); |
| 134 |
this.mTranslationResponseValues = translationResponseValues; |
| 135 |
com.android.internal.util.AnnotationValidations.validate( |
| 136 |
NonNull.class, null, mTranslationResponseValues); |
| 137 |
|
| 138 |
|
| 139 |
} |
| 140 |
|
| 141 |
@Override |
| 142 |
@DataClass.Generated.Member |
| 143 |
public String toString() { |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
return "ViewTranslationResponse { " + |
| 148 |
"autofillId = " + mAutofillId + ", " + |
| 149 |
"translationResponseValues = " + mTranslationResponseValues + |
| 150 |
" }"; |
| 151 |
} |
| 152 |
|
| 153 |
@Override |
| 154 |
@DataClass.Generated.Member |
| 155 |
public boolean equals(@Nullable Object o) { |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
if (this == o) return true; |
| 161 |
if (o == null || getClass() != o.getClass()) return false; |
| 162 |
@SuppressWarnings("unchecked") |
| 163 |
ViewTranslationResponse that = (ViewTranslationResponse) o; |
| 164 |
|
| 165 |
return true |
| 166 |
&& Objects.equals(mAutofillId, that.mAutofillId) |
| 167 |
&& Objects.equals(mTranslationResponseValues, that.mTranslationResponseValues); |
| 168 |
} |
| 169 |
|
| 170 |
@Override |
| 171 |
@DataClass.Generated.Member |
| 172 |
public int hashCode() { |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
int _hash = 1; |
| 177 |
_hash = 31 * _hash + Objects.hashCode(mAutofillId); |
| 178 |
_hash = 31 * _hash + Objects.hashCode(mTranslationResponseValues); |
| 179 |
return _hash; |
| 180 |
} |
| 181 |
|
| 182 |
@Override |
| 183 |
@DataClass.Generated.Member |
| 184 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
dest.writeTypedObject(mAutofillId, flags); |
| 189 |
dest.writeMap(mTranslationResponseValues); |
| 190 |
} |
| 191 |
|
| 192 |
@Override |
| 193 |
@DataClass.Generated.Member |
| 194 |
public int describeContents() { return 0; } |
| 195 |
|
| 196 |
|
| 197 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 198 |
@DataClass.Generated.Member |
| 199 |
ViewTranslationResponse(@NonNull Parcel in) { |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
AutofillId autofillId = (AutofillId) in.readTypedObject(AutofillId.CREATOR); |
| 204 |
Map<String,TranslationResponseValue> translationResponseValues = new java.util.LinkedHashMap<>(); |
| 205 |
in.readMap(translationResponseValues, TranslationResponseValue.class.getClassLoader()); |
| 206 |
|
| 207 |
this.mAutofillId = autofillId; |
| 208 |
com.android.internal.util.AnnotationValidations.validate( |
| 209 |
NonNull.class, null, mAutofillId); |
| 210 |
this.mTranslationResponseValues = translationResponseValues; |
| 211 |
com.android.internal.util.AnnotationValidations.validate( |
| 212 |
NonNull.class, null, mTranslationResponseValues); |
| 213 |
|
| 214 |
|
| 215 |
} |
| 216 |
|
| 217 |
@DataClass.Generated.Member |
| 218 |
public static final @NonNull Parcelable.Creator<ViewTranslationResponse> CREATOR |
| 219 |
= new Parcelable.Creator<ViewTranslationResponse>() { |
| 220 |
@Override |
| 221 |
public ViewTranslationResponse[] newArray(int size) { |
| 222 |
return new ViewTranslationResponse[size]; |
| 223 |
} |
| 224 |
|
| 225 |
@Override |
| 226 |
public ViewTranslationResponse createFromParcel(@NonNull Parcel in) { |
| 227 |
return new ViewTranslationResponse(in); |
| 228 |
} |
| 229 |
}; |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
@SuppressWarnings("WeakerAccess") |
| 235 |
@DataClass.Generated.Member |
| 236 |
public static final class Builder extends BaseBuilder { |
| 237 |
|
| 238 |
private @NonNull AutofillId mAutofillId; |
| 239 |
private @NonNull Map<String,TranslationResponseValue> mTranslationResponseValues; |
| 240 |
|
| 241 |
private long mBuilderFieldsSet = 0L; |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
public Builder( |
| 250 |
@NonNull AutofillId autofillId) { |
| 251 |
mAutofillId = autofillId; |
| 252 |
com.android.internal.util.AnnotationValidations.validate( |
| 253 |
NonNull.class, null, mAutofillId); |
| 254 |
} |
| 255 |
|
| 256 |
@DataClass.Generated.Member |
| 257 |
@Override |
| 258 |
@NonNull Builder setTranslationResponseValues(@NonNull Map<String,TranslationResponseValue> value) { |
| 259 |
checkNotUsed(); |
| 260 |
mBuilderFieldsSet |= 0x2; |
| 261 |
mTranslationResponseValues = value; |
| 262 |
return this; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
public @NonNull ViewTranslationResponse build() { |
| 267 |
checkNotUsed(); |
| 268 |
mBuilderFieldsSet |= 0x4; |
| 269 |
|
| 270 |
if ((mBuilderFieldsSet & 0x2) == 0) { |
| 271 |
mTranslationResponseValues = defaultTranslationResponseValues(); |
| 272 |
} |
| 273 |
ViewTranslationResponse o = new ViewTranslationResponse( |
| 274 |
mAutofillId, |
| 275 |
mTranslationResponseValues); |
| 276 |
return o; |
| 277 |
} |
| 278 |
|
| 279 |
private void checkNotUsed() { |
| 280 |
if ((mBuilderFieldsSet & 0x4) != 0) { |
| 281 |
throw new IllegalStateException( |
| 282 |
"This Builder should not be reused. Use a new Builder instance instead"); |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
@DataClass.Generated( |
| 288 |
time = 1614992272865L, |
| 289 |
codegenVersion = "1.0.22", |
| 290 |
sourceFile = "frameworks/base/core/java/android/view/translation/ViewTranslationResponse.java", |
| 291 |
inputSignatures = "private final @android.annotation.NonNull android.view.autofill.AutofillId mAutofillId\nprivate final @android.annotation.NonNull @com.android.internal.util.DataClass.PluralOf(\"translationResponseValue\") java.util.Map<java.lang.String,android.view.translation.TranslationResponseValue> mTranslationResponseValues\npublic @android.annotation.NonNull android.view.translation.TranslationResponseValue getValue(java.lang.String)\npublic @android.annotation.NonNull java.util.Set<java.lang.String> getKeys()\npublic @android.annotation.NonNull android.view.autofill.AutofillId getAutofillId()\nprivate static java.util.Map<java.lang.String,android.view.translation.TranslationResponseValue> defaultTranslationResponseValues()\nclass ViewTranslationResponse extends java.lang.Object implements [android.os.Parcelable]\nabstract android.view.translation.ViewTranslationResponse.Builder setTranslationResponseValues(java.util.Map<java.lang.String,android.view.translation.TranslationResponseValue>)\npublic @android.annotation.SuppressLint android.view.translation.ViewTranslationResponse.Builder setValue(java.lang.String,android.view.translation.TranslationResponseValue)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true, genGetters=false)\nabstract android.view.translation.ViewTranslationResponse.Builder setTranslationResponseValues(java.util.Map<java.lang.String,android.view.translation.TranslationResponseValue>)\npublic @android.annotation.SuppressLint android.view.translation.ViewTranslationResponse.Builder setValue(java.lang.String,android.view.translation.TranslationResponseValue)\nclass BaseBuilder extends java.lang.Object implements []") |
| 292 |
@Deprecated |
| 293 |
private void __metadata() {} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
} |