blob: e348c77c0ac616b92c22dd52af5735746bf33603 [file] [log] [blame]
Eugene Susla8cb1a412019-10-03 17:22:44 -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.Parcelable;
21
22import com.android.internal.util.DataClass;
23
24/**
25 * An example of data classes that extend one another.
26 *
27 * Note that some features like constructor generation might not work well due to lack of
28 * information about the superclass when generating code for subclass.
29 *
30 * It is recommended to avoid inheritance in favor of composition for new data classes,
31 * particularly parcelable ones.
32 *
33 * However for legacy classes or where inheritance is desired for allocation efficiency,
34 * you can either use a technique from this example, opting for mutability/setters, or just write
35 * constructors by hand.
36 *
37 * @see HierrarchicalDataClassBase
38 */
39@DataClass(
40 genParcelable = true,
41 genConstructor = false,
42 genSetters = true)
43public class HierrarchicalDataClassChild extends HierrarchicalDataClassBase {
44
45 private @NonNull String mChildData;
46
47
48
Eugene Suslac5c636a2019-10-22 10:37:26 -070049 // Code below generated by codegen v1.0.13.
Eugene Susla8cb1a412019-10-03 17:22:44 -070050 //
51 // DO NOT MODIFY!
52 // CHECKSTYLE:OFF Generated code
53 //
54 // To regenerate run:
55 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/tests/Codegen/src/com/android/codegentest/HierrarchicalDataClassChild.java
Eugene Suslaf821caa2019-10-04 14:51:29 -070056 //
57 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
58 // Settings > Editor > Code Style > Formatter Control
59 //@formatter:off
Eugene Susla8cb1a412019-10-03 17:22:44 -070060
61
62 @DataClass.Generated.Member
63 public @NonNull String getChildData() {
64 return mChildData;
65 }
66
67 @DataClass.Generated.Member
68 public HierrarchicalDataClassChild setChildData(@NonNull String value) {
69 mChildData = value;
70 com.android.internal.util.AnnotationValidations.validate(
71 NonNull.class, null, mChildData);
72 return this;
73 }
74
75 @Override
76 @DataClass.Generated.Member
Eugene Susla1bfb5e72019-10-16 10:12:47 -070077 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
Eugene Susla8cb1a412019-10-03 17:22:44 -070078 // You can override field parcelling by defining methods like:
79 // void parcelFieldName(Parcel dest, int flags) { ... }
80
81 super.writeToParcel(dest, flags);
82
83 dest.writeString(mChildData);
84 }
85
86 @Override
87 @DataClass.Generated.Member
88 public int describeContents() { return 0; }
89
90 /** @hide */
91 @SuppressWarnings({"unchecked", "RedundantCast"})
92 @DataClass.Generated.Member
Eugene Susla1bfb5e72019-10-16 10:12:47 -070093 protected HierrarchicalDataClassChild(@NonNull android.os.Parcel in) {
Eugene Susla8cb1a412019-10-03 17:22:44 -070094 // You can override field unparcelling by defining methods like:
95 // static FieldType unparcelFieldName(Parcel in) { ... }
96
97 super(in);
98
99 String childData = in.readString();
100
101 this.mChildData = childData;
102 com.android.internal.util.AnnotationValidations.validate(
103 NonNull.class, null, mChildData);
104
105 // onConstructed(); // You can define this method to get a callback
106 }
107
108 @DataClass.Generated.Member
109 public static final @NonNull Parcelable.Creator<HierrarchicalDataClassChild> CREATOR
110 = new Parcelable.Creator<HierrarchicalDataClassChild>() {
111 @Override
112 public HierrarchicalDataClassChild[] newArray(int size) {
113 return new HierrarchicalDataClassChild[size];
114 }
115
116 @Override
Eugene Susla1bfb5e72019-10-16 10:12:47 -0700117 public HierrarchicalDataClassChild createFromParcel(@NonNull android.os.Parcel in) {
Eugene Susla8cb1a412019-10-03 17:22:44 -0700118 return new HierrarchicalDataClassChild(in);
119 }
120 };
121
122 @DataClass.Generated(
Eugene Suslac5c636a2019-10-22 10:37:26 -0700123 time = 1573006406833L,
124 codegenVersion = "1.0.13",
Eugene Susla8cb1a412019-10-03 17:22:44 -0700125 sourceFile = "frameworks/base/tests/Codegen/src/com/android/codegentest/HierrarchicalDataClassChild.java",
126 inputSignatures = "private @android.annotation.NonNull java.lang.String mChildData\nclass HierrarchicalDataClassChild extends com.android.codegentest.HierrarchicalDataClassBase implements []\n@com.android.internal.util.DataClass(genParcelable=true, genConstructor=false, genSetters=true)")
127 @Deprecated
128 private void __metadata() {}
129
Eugene Susla322e8b12019-10-22 17:32:08 -0700130
131 //@formatter:on
132 // End of generated code
133
Eugene Susla8cb1a412019-10-03 17:22:44 -0700134}