Debian Codegraph @

core/java/android/view/translation/TranslationRequestValue.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.view.translation;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 import com.android.internal.util.DataClass;
25
26 import java.util.Objects;
27
28 /**
29 * A value to be translated via {@link android.view.translation.Translator}.
30 */
31 @DataClass(genHiddenConstructor = true, genToString = true, genEqualsHashCode = true)
32 public final class TranslationRequestValue implements Parcelable {
33
34 @Nullable
35 private final CharSequence mText;
36
37 /**
38 * Creates a {@link TranslationRequestValue} with a {@link CharSequence} value;
39 *
40 * @param text the text to be translated.
41 */
42 @NonNull
43 public static TranslationRequestValue forText(@NonNull CharSequence text) {
44 Objects.requireNonNull(text, "text should not be null");
45 return new TranslationRequestValue(text);
46 }
47
48 /**
49 * @return the text value as a {@link CharSequence} or {@code null} if the value is not of type
50 * text.
51 */
52 @Nullable
53 public CharSequence getText() {
54 return mText;
55 }
56
57
58
59 // Code below generated by codegen v1.0.23.
60 //
61 // DO NOT MODIFY!
62 // CHECKSTYLE:OFF Generated code
63 //
64 // To regenerate run:
65 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/translation/TranslationRequestValue.java
66 //
67 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
68 // Settings > Editor > Code Style > Formatter Control
69 //@formatter:off
70
71
72 /**
73 * Creates a new TranslationRequestValue.
74 *
75 * @hide
76 */
77 @DataClass.Generated.Member
78 public TranslationRequestValue(
79 @Nullable CharSequence text) {
80 this.mText = text;
81
82 // onConstructed(); // You can define this method to get a callback
83 }
84
85 @Override
86 @DataClass.Generated.Member
87 public String toString() {
88 // You can override field toString logic by defining methods like:
89 // String fieldNameToString() { ... }
90
91 return "TranslationRequestValue { " +
92 "text = " + mText +
93 " }";
94 }
95
96 @Override
97 @DataClass.Generated.Member
98 public boolean equals(@Nullable Object o) {
99 // You can override field equality logic by defining either of the methods like:
100 // boolean fieldNameEquals(TranslationRequestValue other) { ... }
101 // boolean fieldNameEquals(FieldType otherValue) { ... }
102
103 if (this == o) return true;
104 if (o == null || getClass() != o.getClass()) return false;
105 @SuppressWarnings("unchecked")
106 TranslationRequestValue that = (TranslationRequestValue) o;
107 //noinspection PointlessBooleanExpression
108 return true
109 && Objects.equals(mText, that.mText);
110 }
111
112 @Override
113 @DataClass.Generated.Member
114 public int hashCode() {
115 // You can override field hashCode logic by defining methods like:
116 // int fieldNameHashCode() { ... }
117
118 int _hash = 1;
119 _hash = 31 * _hash + Objects.hashCode(mText);
120 return _hash;
121 }
122
123 @Override
124 @DataClass.Generated.Member
125 public void writeToParcel(@NonNull Parcel dest, int flags) {
126 // You can override field parcelling by defining methods like:
127 // void parcelFieldName(Parcel dest, int flags) { ... }
128
129 byte flg = 0;
130 if (mText != null) flg |= 0x1;
131 dest.writeByte(flg);
132 if (mText != null) dest.writeCharSequence(mText);
133 }
134
135 @Override
136 @DataClass.Generated.Member
137 public int describeContents() { return 0; }
138
139 /** @hide */
140 @SuppressWarnings({"unchecked", "RedundantCast"})
141 @DataClass.Generated.Member
142 /* package-private */ TranslationRequestValue(@NonNull Parcel in) {
143 // You can override field unparcelling by defining methods like:
144 // static FieldType unparcelFieldName(Parcel in) { ... }
145
146 byte flg = in.readByte();
147 CharSequence text = (flg & 0x1) == 0 ? null : (CharSequence) in.readCharSequence();
148
149 this.mText = text;
150
151 // onConstructed(); // You can define this method to get a callback
152 }
153
154 @DataClass.Generated.Member
155 public static final @NonNull Parcelable.Creator<TranslationRequestValue> CREATOR
156 = new Parcelable.Creator<TranslationRequestValue>() {
157 @Override
158 public TranslationRequestValue[] newArray(int size) {
159 return new TranslationRequestValue[size];
160 }
161
162 @Override
163 public TranslationRequestValue createFromParcel(@NonNull Parcel in) {
164 return new TranslationRequestValue(in);
165 }
166 };
167
168 @DataClass.Generated(
169 time = 1620259864154L,
170 codegenVersion = "1.0.23",
171 sourceFile = "frameworks/base/core/java/android/view/translation/TranslationRequestValue.java",
172 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)")
173 @Deprecated
174 private void __metadata() {}
175
176
177 //@formatter:on
178 // End of generated code
179
180 }