blob: 406e599a67fb1a020084455db35781f6fad6bd89 [file] [log] [blame]
Feng Cao04830a32019-11-13 00:45:19 -08001/*
2 * Copyright (C) 2019 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
17package android.view.inline;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
Adam He40116252020-02-04 14:55:39 -080021import android.annotation.SystemApi;
Feng Cao04830a32019-11-13 00:45:19 -080022import android.os.Parcelable;
23import android.util.Size;
24
25import com.android.internal.util.DataClass;
26
27/**
28 * This class represents the presentation specification by which an inline suggestion
29 * should abide when constructing its UI. Since suggestions are inlined in a
30 * host application while provided by another source, they need to be consistent
31 * with the host's look at feel to allow building smooth and integrated UIs.
32 */
33@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
34public final class InlinePresentationSpec implements Parcelable {
Feng Cao7a0f0022019-12-17 18:49:24 -080035
Feng Cao04830a32019-11-13 00:45:19 -080036 /** The minimal size of the suggestion. */
37 @NonNull
38 private final Size mMinSize;
39 /** The maximal size of the suggestion. */
40 @NonNull
41 private final Size mMaxSize;
42
Feng Cao7a0f0022019-12-17 18:49:24 -080043 /**
44 * The fully qualified resource name of the UI style resource identifier, defaults to {@code
45 * null}.
46 *
47 * <p> The value can be obtained by calling {@code Resources#getResourceName(int)}.
48 */
49 @Nullable
50 private final String mStyle;
51
52 private static String defaultStyle() {
53 return null;
54 }
55
56 /**
57 * @hide
58 */
Adam He40116252020-02-04 14:55:39 -080059 @SystemApi
Feng Cao7a0f0022019-12-17 18:49:24 -080060 public @Nullable String getStyle() {
61 return mStyle;
62 }
63
Feng Cao04830a32019-11-13 00:45:19 -080064
65 /** @hide */
66 @DataClass.Suppress({"setMaxSize", "setMinSize"})
67 abstract static class BaseBuilder {
68 }
69
70
71
72 // Code below generated by codegen v1.0.14.
73 //
74 // DO NOT MODIFY!
75 // CHECKSTYLE:OFF Generated code
76 //
77 // To regenerate run:
78 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java
79 //
80 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
81 // Settings > Editor > Code Style > Formatter Control
82 //@formatter:off
83
84
85 @DataClass.Generated.Member
86 /* package-private */ InlinePresentationSpec(
87 @NonNull Size minSize,
Feng Cao7a0f0022019-12-17 18:49:24 -080088 @NonNull Size maxSize,
89 @Nullable String style) {
Feng Cao04830a32019-11-13 00:45:19 -080090 this.mMinSize = minSize;
91 com.android.internal.util.AnnotationValidations.validate(
92 NonNull.class, null, mMinSize);
93 this.mMaxSize = maxSize;
94 com.android.internal.util.AnnotationValidations.validate(
95 NonNull.class, null, mMaxSize);
Feng Cao7a0f0022019-12-17 18:49:24 -080096 this.mStyle = style;
Feng Cao04830a32019-11-13 00:45:19 -080097
98 // onConstructed(); // You can define this method to get a callback
99 }
100
101 /**
102 * The minimal size of the suggestion.
103 */
104 @DataClass.Generated.Member
105 public @NonNull Size getMinSize() {
106 return mMinSize;
107 }
108
109 /**
110 * The maximal size of the suggestion.
111 */
112 @DataClass.Generated.Member
113 public @NonNull Size getMaxSize() {
114 return mMaxSize;
115 }
116
117 @Override
118 @DataClass.Generated.Member
119 public String toString() {
120 // You can override field toString logic by defining methods like:
121 // String fieldNameToString() { ... }
122
123 return "InlinePresentationSpec { " +
124 "minSize = " + mMinSize + ", " +
Feng Cao7a0f0022019-12-17 18:49:24 -0800125 "maxSize = " + mMaxSize + ", " +
126 "style = " + mStyle +
Feng Cao04830a32019-11-13 00:45:19 -0800127 " }";
128 }
129
130 @Override
131 @DataClass.Generated.Member
132 public boolean equals(@Nullable Object o) {
133 // You can override field equality logic by defining either of the methods like:
134 // boolean fieldNameEquals(InlinePresentationSpec other) { ... }
135 // boolean fieldNameEquals(FieldType otherValue) { ... }
136
137 if (this == o) return true;
138 if (o == null || getClass() != o.getClass()) return false;
139 @SuppressWarnings("unchecked")
140 InlinePresentationSpec that = (InlinePresentationSpec) o;
141 //noinspection PointlessBooleanExpression
142 return true
143 && java.util.Objects.equals(mMinSize, that.mMinSize)
Feng Cao7a0f0022019-12-17 18:49:24 -0800144 && java.util.Objects.equals(mMaxSize, that.mMaxSize)
145 && java.util.Objects.equals(mStyle, that.mStyle);
Feng Cao04830a32019-11-13 00:45:19 -0800146 }
147
148 @Override
149 @DataClass.Generated.Member
150 public int hashCode() {
151 // You can override field hashCode logic by defining methods like:
152 // int fieldNameHashCode() { ... }
153
154 int _hash = 1;
155 _hash = 31 * _hash + java.util.Objects.hashCode(mMinSize);
156 _hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
Feng Cao7a0f0022019-12-17 18:49:24 -0800157 _hash = 31 * _hash + java.util.Objects.hashCode(mStyle);
Feng Cao04830a32019-11-13 00:45:19 -0800158 return _hash;
159 }
160
161 @Override
162 @DataClass.Generated.Member
163 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
164 // You can override field parcelling by defining methods like:
165 // void parcelFieldName(Parcel dest, int flags) { ... }
166
Feng Cao7a0f0022019-12-17 18:49:24 -0800167 byte flg = 0;
168 if (mStyle != null) flg |= 0x4;
169 dest.writeByte(flg);
Feng Cao04830a32019-11-13 00:45:19 -0800170 dest.writeSize(mMinSize);
171 dest.writeSize(mMaxSize);
Feng Cao7a0f0022019-12-17 18:49:24 -0800172 if (mStyle != null) dest.writeString(mStyle);
Feng Cao04830a32019-11-13 00:45:19 -0800173 }
174
175 @Override
176 @DataClass.Generated.Member
177 public int describeContents() { return 0; }
178
179 /** @hide */
180 @SuppressWarnings({"unchecked", "RedundantCast"})
181 @DataClass.Generated.Member
182 /* package-private */ InlinePresentationSpec(@NonNull android.os.Parcel in) {
183 // You can override field unparcelling by defining methods like:
184 // static FieldType unparcelFieldName(Parcel in) { ... }
185
Feng Cao7a0f0022019-12-17 18:49:24 -0800186 byte flg = in.readByte();
Feng Cao04830a32019-11-13 00:45:19 -0800187 Size minSize = (Size) in.readSize();
188 Size maxSize = (Size) in.readSize();
Feng Cao7a0f0022019-12-17 18:49:24 -0800189 String style = (flg & 0x4) == 0 ? null : in.readString();
Feng Cao04830a32019-11-13 00:45:19 -0800190
191 this.mMinSize = minSize;
192 com.android.internal.util.AnnotationValidations.validate(
193 NonNull.class, null, mMinSize);
194 this.mMaxSize = maxSize;
195 com.android.internal.util.AnnotationValidations.validate(
196 NonNull.class, null, mMaxSize);
Feng Cao7a0f0022019-12-17 18:49:24 -0800197 this.mStyle = style;
Feng Cao04830a32019-11-13 00:45:19 -0800198
199 // onConstructed(); // You can define this method to get a callback
200 }
201
202 @DataClass.Generated.Member
203 public static final @NonNull Parcelable.Creator<InlinePresentationSpec> CREATOR
204 = new Parcelable.Creator<InlinePresentationSpec>() {
205 @Override
206 public InlinePresentationSpec[] newArray(int size) {
207 return new InlinePresentationSpec[size];
208 }
209
210 @Override
211 public InlinePresentationSpec createFromParcel(@NonNull android.os.Parcel in) {
212 return new InlinePresentationSpec(in);
213 }
214 };
215
216 /**
217 * A builder for {@link InlinePresentationSpec}
218 */
219 @SuppressWarnings("WeakerAccess")
220 @DataClass.Generated.Member
221 public static final class Builder extends BaseBuilder {
222
223 private @NonNull Size mMinSize;
224 private @NonNull Size mMaxSize;
Feng Cao7a0f0022019-12-17 18:49:24 -0800225 private @Nullable String mStyle;
Feng Cao04830a32019-11-13 00:45:19 -0800226
227 private long mBuilderFieldsSet = 0L;
228
229 /**
230 * Creates a new Builder.
231 *
232 * @param minSize
233 * The minimal size of the suggestion.
234 * @param maxSize
235 * The maximal size of the suggestion.
236 */
237 public Builder(
238 @NonNull Size minSize,
239 @NonNull Size maxSize) {
240 mMinSize = minSize;
241 com.android.internal.util.AnnotationValidations.validate(
242 NonNull.class, null, mMinSize);
243 mMaxSize = maxSize;
244 com.android.internal.util.AnnotationValidations.validate(
245 NonNull.class, null, mMaxSize);
246 }
247
Feng Cao7a0f0022019-12-17 18:49:24 -0800248 /**
249 * The fully qualified resource name of the UI style resource identifier, defaults to {@code
250 * null}.
251 *
252 * <p> The value can be obtained by calling {@code Resources#getResourceName(int)}.
253 */
254 @DataClass.Generated.Member
255 public @NonNull Builder setStyle(@Nullable String value) {
256 checkNotUsed();
257 mBuilderFieldsSet |= 0x4;
258 mStyle = value;
259 return this;
260 }
261
Feng Cao04830a32019-11-13 00:45:19 -0800262 /** Builds the instance. This builder should not be touched after calling this! */
263 public @NonNull InlinePresentationSpec build() {
264 checkNotUsed();
Feng Cao7a0f0022019-12-17 18:49:24 -0800265 mBuilderFieldsSet |= 0x8; // Mark builder used
Feng Cao04830a32019-11-13 00:45:19 -0800266
Feng Cao7a0f0022019-12-17 18:49:24 -0800267 if ((mBuilderFieldsSet & 0x4) == 0) {
268 mStyle = defaultStyle();
269 }
Feng Cao04830a32019-11-13 00:45:19 -0800270 InlinePresentationSpec o = new InlinePresentationSpec(
271 mMinSize,
Feng Cao7a0f0022019-12-17 18:49:24 -0800272 mMaxSize,
273 mStyle);
Feng Cao04830a32019-11-13 00:45:19 -0800274 return o;
275 }
276
277 private void checkNotUsed() {
Feng Cao7a0f0022019-12-17 18:49:24 -0800278 if ((mBuilderFieldsSet & 0x8) != 0) {
Feng Cao04830a32019-11-13 00:45:19 -0800279 throw new IllegalStateException(
280 "This Builder should not be reused. Use a new Builder instance instead");
281 }
282 }
283 }
284
285 @DataClass.Generated(
Adam He40116252020-02-04 14:55:39 -0800286 time = 1581117017522L,
Feng Cao04830a32019-11-13 00:45:19 -0800287 codegenVersion = "1.0.14",
288 sourceFile = "frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java",
Adam He40116252020-02-04 14:55:39 -0800289 inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.Nullable java.lang.String mStyle\nprivate static java.lang.String defaultStyle()\npublic @android.annotation.SystemApi @android.annotation.Nullable java.lang.String getStyle()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []")
Feng Cao04830a32019-11-13 00:45:19 -0800290 @Deprecated
291 private void __metadata() {}
292
293
294 //@formatter:on
295 // End of generated code
296
297}