blob: 0deffe44838feacabcac95dd2fe925fc72396825 [file] [log] [blame]
Eugene Susla322e8b12019-10-22 17:32:08 -07001/*
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 com.android.codegentest;
18
19import android.annotation.NonNull;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23import com.android.internal.util.DataClass;
24
25/**
26 * An example of deeply nested data classes
27 */
28public class SampleWithNestedDataClasses {
29
30 int mFoo = 0;
31
32 @DataClass(genEqualsHashCode = true)
33 public static class NestedDataClass implements Parcelable {
34
35 @NonNull String mBar;
36
37
38
Eugene Suslaf7450422019-11-18 16:09:52 -080039 // Code below generated by codegen v1.0.14.
Eugene Susla322e8b12019-10-22 17:32:08 -070040 //
41 // DO NOT MODIFY!
42 // CHECKSTYLE:OFF Generated code
43 //
44 // To regenerate run:
45 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java
46 //
47 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
48 // Settings > Editor > Code Style > Formatter Control
49 //@formatter:off
50
51
52 @DataClass.Generated.Member
53 public NestedDataClass(
54 @NonNull String bar) {
55 this.mBar = bar;
56 com.android.internal.util.AnnotationValidations.validate(
57 NonNull.class, null, mBar);
58
59 // onConstructed(); // You can define this method to get a callback
60 }
61
62 @DataClass.Generated.Member
63 public @NonNull String getBar() {
64 return mBar;
65 }
66
67 @Override
68 @DataClass.Generated.Member
69 public boolean equals(@android.annotation.Nullable Object o) {
70 // You can override field equality logic by defining either of the methods like:
71 // boolean fieldNameEquals(NestedDataClass other) { ... }
72 // boolean fieldNameEquals(FieldType otherValue) { ... }
73
74 if (this == o) return true;
75 if (o == null || getClass() != o.getClass()) return false;
76 @SuppressWarnings("unchecked")
77 NestedDataClass that = (NestedDataClass) o;
78 //noinspection PointlessBooleanExpression
79 return true
80 && java.util.Objects.equals(mBar, that.mBar);
81 }
82
83 @Override
84 @DataClass.Generated.Member
85 public int hashCode() {
86 // You can override field hashCode logic by defining methods like:
87 // int fieldNameHashCode() { ... }
88
89 int _hash = 1;
90 _hash = 31 * _hash + java.util.Objects.hashCode(mBar);
91 return _hash;
92 }
93
94 @Override
95 @DataClass.Generated.Member
96 public void writeToParcel(@NonNull Parcel dest, int flags) {
97 // You can override field parcelling by defining methods like:
98 // void parcelFieldName(Parcel dest, int flags) { ... }
99
100 dest.writeString(mBar);
101 }
102
103 @Override
104 @DataClass.Generated.Member
105 public int describeContents() { return 0; }
106
107 /** @hide */
108 @SuppressWarnings({"unchecked", "RedundantCast"})
109 @DataClass.Generated.Member
110 protected NestedDataClass(@NonNull Parcel in) {
111 // You can override field unparcelling by defining methods like:
112 // static FieldType unparcelFieldName(Parcel in) { ... }
113
114 String bar = in.readString();
115
116 this.mBar = bar;
117 com.android.internal.util.AnnotationValidations.validate(
118 NonNull.class, null, mBar);
119
120 // onConstructed(); // You can define this method to get a callback
121 }
122
123 @DataClass.Generated.Member
124 public static final @NonNull Parcelable.Creator<NestedDataClass> CREATOR
125 = new Parcelable.Creator<NestedDataClass>() {
126 @Override
127 public NestedDataClass[] newArray(int size) {
128 return new NestedDataClass[size];
129 }
130
131 @Override
132 public NestedDataClass createFromParcel(@NonNull Parcel in) {
133 return new NestedDataClass(in);
134 }
135 };
136
137 @DataClass.Generated(
Eugene Suslaf7450422019-11-18 16:09:52 -0800138 time = 1574122840588L,
139 codegenVersion = "1.0.14",
Eugene Susla322e8b12019-10-22 17:32:08 -0700140 sourceFile = "frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java",
141 inputSignatures = " @android.annotation.NonNull java.lang.String mBar\nclass NestedDataClass extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true)")
142 @Deprecated
143 private void __metadata() {}
144
145
146 //@formatter:on
147 // End of generated code
148
149 }
150
151 @DataClass(genEqualsHashCode = true)
152 public static class NestedDataClass2 implements Parcelable {
153
154 @NonNull String mBaz;
155
156 @DataClass(genEqualsHashCode = true)
157 public static class NestedDataClass3 implements Parcelable {
158
159 @NonNull long mBaz2;
160
161
162
Eugene Suslaf7450422019-11-18 16:09:52 -0800163 // Code below generated by codegen v1.0.14.
Eugene Susla322e8b12019-10-22 17:32:08 -0700164 //
165 // DO NOT MODIFY!
166 // CHECKSTYLE:OFF Generated code
167 //
168 // To regenerate run:
169 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java
170 //
171 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
172 // Settings > Editor > Code Style > Formatter Control
173 //@formatter:off
174
175
176 @DataClass.Generated.Member
177 public NestedDataClass3(
178 @NonNull long baz2) {
179 this.mBaz2 = baz2;
180 com.android.internal.util.AnnotationValidations.validate(
181 NonNull.class, null, mBaz2);
182
183 // onConstructed(); // You can define this method to get a callback
184 }
185
186 @DataClass.Generated.Member
187 public @NonNull long getBaz2() {
188 return mBaz2;
189 }
190
191 @Override
192 @DataClass.Generated.Member
193 public boolean equals(@android.annotation.Nullable Object o) {
194 // You can override field equality logic by defining either of the methods like:
195 // boolean fieldNameEquals(NestedDataClass3 other) { ... }
196 // boolean fieldNameEquals(FieldType otherValue) { ... }
197
198 if (this == o) return true;
199 if (o == null || getClass() != o.getClass()) return false;
200 @SuppressWarnings("unchecked")
201 NestedDataClass3 that = (NestedDataClass3) o;
202 //noinspection PointlessBooleanExpression
203 return true
204 && mBaz2 == that.mBaz2;
205 }
206
207 @Override
208 @DataClass.Generated.Member
209 public int hashCode() {
210 // You can override field hashCode logic by defining methods like:
211 // int fieldNameHashCode() { ... }
212
213 int _hash = 1;
214 _hash = 31 * _hash + Long.hashCode(mBaz2);
215 return _hash;
216 }
217
218 @Override
219 @DataClass.Generated.Member
220 public void writeToParcel(@NonNull Parcel dest, int flags) {
221 // You can override field parcelling by defining methods like:
222 // void parcelFieldName(Parcel dest, int flags) { ... }
223
224 dest.writeLong(mBaz2);
225 }
226
227 @Override
228 @DataClass.Generated.Member
229 public int describeContents() { return 0; }
230
231 /** @hide */
232 @SuppressWarnings({"unchecked", "RedundantCast"})
233 @DataClass.Generated.Member
234 protected NestedDataClass3(@NonNull Parcel in) {
235 // You can override field unparcelling by defining methods like:
236 // static FieldType unparcelFieldName(Parcel in) { ... }
237
238 long baz2 = in.readLong();
239
240 this.mBaz2 = baz2;
241 com.android.internal.util.AnnotationValidations.validate(
242 NonNull.class, null, mBaz2);
243
244 // onConstructed(); // You can define this method to get a callback
245 }
246
247 @DataClass.Generated.Member
248 public static final @NonNull Parcelable.Creator<NestedDataClass3> CREATOR
249 = new Parcelable.Creator<NestedDataClass3>() {
250 @Override
251 public NestedDataClass3[] newArray(int size) {
252 return new NestedDataClass3[size];
253 }
254
255 @Override
256 public NestedDataClass3 createFromParcel(@NonNull Parcel in) {
257 return new NestedDataClass3(in);
258 }
259 };
260
261 @DataClass.Generated(
Eugene Suslaf7450422019-11-18 16:09:52 -0800262 time = 1574122840597L,
263 codegenVersion = "1.0.14",
Eugene Susla322e8b12019-10-22 17:32:08 -0700264 sourceFile = "frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java",
265 inputSignatures = " @android.annotation.NonNull long mBaz2\nclass NestedDataClass3 extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true)")
266 @Deprecated
267 private void __metadata() {}
268
269
270 //@formatter:on
271 // End of generated code
272
273 }
274
275
276
Eugene Suslaf7450422019-11-18 16:09:52 -0800277 // Code below generated by codegen v1.0.14.
Eugene Susla322e8b12019-10-22 17:32:08 -0700278 //
279 // DO NOT MODIFY!
280 // CHECKSTYLE:OFF Generated code
281 //
282 // To regenerate run:
283 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java
284 //
285 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
286 // Settings > Editor > Code Style > Formatter Control
287 //@formatter:off
288
289
290 @DataClass.Generated.Member
291 public NestedDataClass2(
292 @NonNull String baz) {
293 this.mBaz = baz;
294 com.android.internal.util.AnnotationValidations.validate(
295 NonNull.class, null, mBaz);
296
297 // onConstructed(); // You can define this method to get a callback
298 }
299
300 @DataClass.Generated.Member
301 public @NonNull String getBaz() {
302 return mBaz;
303 }
304
305 @Override
306 @DataClass.Generated.Member
307 public boolean equals(@android.annotation.Nullable Object o) {
308 // You can override field equality logic by defining either of the methods like:
309 // boolean fieldNameEquals(NestedDataClass2 other) { ... }
310 // boolean fieldNameEquals(FieldType otherValue) { ... }
311
312 if (this == o) return true;
313 if (o == null || getClass() != o.getClass()) return false;
314 @SuppressWarnings("unchecked")
315 NestedDataClass2 that = (NestedDataClass2) o;
316 //noinspection PointlessBooleanExpression
317 return true
318 && java.util.Objects.equals(mBaz, that.mBaz);
319 }
320
321 @Override
322 @DataClass.Generated.Member
323 public int hashCode() {
324 // You can override field hashCode logic by defining methods like:
325 // int fieldNameHashCode() { ... }
326
327 int _hash = 1;
328 _hash = 31 * _hash + java.util.Objects.hashCode(mBaz);
329 return _hash;
330 }
331
332 @Override
333 @DataClass.Generated.Member
334 public void writeToParcel(@NonNull Parcel dest, int flags) {
335 // You can override field parcelling by defining methods like:
336 // void parcelFieldName(Parcel dest, int flags) { ... }
337
338 dest.writeString(mBaz);
339 }
340
341 @Override
342 @DataClass.Generated.Member
343 public int describeContents() { return 0; }
344
345 /** @hide */
346 @SuppressWarnings({"unchecked", "RedundantCast"})
347 @DataClass.Generated.Member
348 protected NestedDataClass2(@NonNull Parcel in) {
349 // You can override field unparcelling by defining methods like:
350 // static FieldType unparcelFieldName(Parcel in) { ... }
351
352 String baz = in.readString();
353
354 this.mBaz = baz;
355 com.android.internal.util.AnnotationValidations.validate(
356 NonNull.class, null, mBaz);
357
358 // onConstructed(); // You can define this method to get a callback
359 }
360
361 @DataClass.Generated.Member
362 public static final @NonNull Parcelable.Creator<NestedDataClass2> CREATOR
363 = new Parcelable.Creator<NestedDataClass2>() {
364 @Override
365 public NestedDataClass2[] newArray(int size) {
366 return new NestedDataClass2[size];
367 }
368
369 @Override
370 public NestedDataClass2 createFromParcel(@NonNull Parcel in) {
371 return new NestedDataClass2(in);
372 }
373 };
374
375 @DataClass.Generated(
Eugene Suslaf7450422019-11-18 16:09:52 -0800376 time = 1574122840608L,
377 codegenVersion = "1.0.14",
Eugene Susla322e8b12019-10-22 17:32:08 -0700378 sourceFile = "frameworks/base/tests/Codegen/src/com/android/codegentest/SampleWithNestedDataClasses.java",
379 inputSignatures = " @android.annotation.NonNull java.lang.String mBaz\nclass NestedDataClass2 extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true)")
380 @Deprecated
381 private void __metadata() {}
382
383
384 //@formatter:on
385 // End of generated code
386
387 }
388
389 void someCode() {}
390}