• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.ondevicepersonalization;
18 
19 import android.annotation.Nullable;
20 import android.os.Parcelable;
21 import android.os.PersistableBundle;
22 
23 import com.android.ondevicepersonalization.internal.util.DataClass;
24 
25 /**
26  * The output to be rendered in a slot within a calling app.
27  *
28  * @hide
29  */
30 @DataClass(genBuilder = true, genEqualsHashCode = true)
31 public final class RenderOutput implements Parcelable {
32     /** The content to be rendered. */
33     @Nullable private String mContent = "";
34 
35     /**
36      * Parameters for template rendering
37      */
38     @Nullable private PersistableBundle mTemplateParams;
39 
40     /**
41      * Template ID to retrieve from REMOTE_DATA for rendering
42      */
43     @Nullable private String mTemplateId;
44 
45 
46 
47 
48     // Code below generated by codegen v1.0.23.
49     //
50     // DO NOT MODIFY!
51     // CHECKSTYLE:OFF Generated code
52     //
53     // To regenerate run:
54     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/RenderOutput.java
55     //
56     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
57     //   Settings > Editor > Code Style > Formatter Control
58     //@formatter:off
59 
60 
61     @DataClass.Generated.Member
RenderOutput( @ullable String content, @Nullable PersistableBundle templateParams, @Nullable String templateId)62     /* package-private */ RenderOutput(
63             @Nullable String content,
64             @Nullable PersistableBundle templateParams,
65             @Nullable String templateId) {
66         this.mContent = content;
67         this.mTemplateParams = templateParams;
68         this.mTemplateId = templateId;
69 
70         // onConstructed(); // You can define this method to get a callback
71     }
72 
73     /**
74      * The content to be rendered.
75      */
76     @DataClass.Generated.Member
getContent()77     public @Nullable String getContent() {
78         return mContent;
79     }
80 
81     /**
82      * Parameters for template rendering
83      */
84     @DataClass.Generated.Member
getTemplateParams()85     public @Nullable PersistableBundle getTemplateParams() {
86         return mTemplateParams;
87     }
88 
89     /**
90      * Template ID to retrieve from REMOTE_DATA for rendering
91      */
92     @DataClass.Generated.Member
getTemplateId()93     public @Nullable String getTemplateId() {
94         return mTemplateId;
95     }
96 
97     @Override
98     @DataClass.Generated.Member
equals(@ullable Object o)99     public boolean equals(@Nullable Object o) {
100         // You can override field equality logic by defining either of the methods like:
101         // boolean fieldNameEquals(RenderOutput other) { ... }
102         // boolean fieldNameEquals(FieldType otherValue) { ... }
103 
104         if (this == o) return true;
105         if (o == null || getClass() != o.getClass()) return false;
106         @SuppressWarnings("unchecked")
107         RenderOutput that = (RenderOutput) o;
108         //noinspection PointlessBooleanExpression
109         return true
110                 && java.util.Objects.equals(mContent, that.mContent)
111                 && java.util.Objects.equals(mTemplateParams, that.mTemplateParams)
112                 && java.util.Objects.equals(mTemplateId, that.mTemplateId);
113     }
114 
115     @Override
116     @DataClass.Generated.Member
hashCode()117     public int hashCode() {
118         // You can override field hashCode logic by defining methods like:
119         // int fieldNameHashCode() { ... }
120 
121         int _hash = 1;
122         _hash = 31 * _hash + java.util.Objects.hashCode(mContent);
123         _hash = 31 * _hash + java.util.Objects.hashCode(mTemplateParams);
124         _hash = 31 * _hash + java.util.Objects.hashCode(mTemplateId);
125         return _hash;
126     }
127 
128     @Override
129     @DataClass.Generated.Member
writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)130     public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) {
131         // You can override field parcelling by defining methods like:
132         // void parcelFieldName(Parcel dest, int flags) { ... }
133 
134         byte flg = 0;
135         if (mContent != null) flg |= 0x1;
136         if (mTemplateParams != null) flg |= 0x2;
137         if (mTemplateId != null) flg |= 0x4;
138         dest.writeByte(flg);
139         if (mContent != null) dest.writeString(mContent);
140         if (mTemplateParams != null) dest.writeTypedObject(mTemplateParams, flags);
141         if (mTemplateId != null) dest.writeString(mTemplateId);
142     }
143 
144     @Override
145     @DataClass.Generated.Member
describeContents()146     public int describeContents() { return 0; }
147 
148     /** @hide */
149     @SuppressWarnings({"unchecked", "RedundantCast"})
150     @DataClass.Generated.Member
RenderOutput(@ndroid.annotation.NonNull android.os.Parcel in)151     /* package-private */ RenderOutput(@android.annotation.NonNull android.os.Parcel in) {
152         // You can override field unparcelling by defining methods like:
153         // static FieldType unparcelFieldName(Parcel in) { ... }
154 
155         byte flg = in.readByte();
156         String content = (flg & 0x1) == 0 ? null : in.readString();
157         PersistableBundle templateParams = (flg & 0x2) == 0 ? null : (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR);
158         String templateId = (flg & 0x4) == 0 ? null : in.readString();
159 
160         this.mContent = content;
161         this.mTemplateParams = templateParams;
162         this.mTemplateId = templateId;
163 
164         // onConstructed(); // You can define this method to get a callback
165     }
166 
167     @DataClass.Generated.Member
168     public static final @android.annotation.NonNull Parcelable.Creator<RenderOutput> CREATOR
169             = new Parcelable.Creator<RenderOutput>() {
170         @Override
171         public RenderOutput[] newArray(int size) {
172             return new RenderOutput[size];
173         }
174 
175         @Override
176         public RenderOutput createFromParcel(@android.annotation.NonNull android.os.Parcel in) {
177             return new RenderOutput(in);
178         }
179     };
180 
181     /**
182      * A builder for {@link RenderOutput}
183      */
184     @SuppressWarnings("WeakerAccess")
185     @DataClass.Generated.Member
186     public static final class Builder {
187 
188         private @Nullable String mContent;
189         private @Nullable PersistableBundle mTemplateParams;
190         private @Nullable String mTemplateId;
191 
192         private long mBuilderFieldsSet = 0L;
193 
Builder()194         public Builder() {
195         }
196 
197         /**
198          * Creates a new Builder.
199          *
200          * @param templateParams
201          *   Parameters for template rendering
202          * @param templateId
203          *   Template ID to retrieve from REMOTE_DATA for rendering
204          */
Builder( @ullable PersistableBundle templateParams, @Nullable String templateId)205         public Builder(
206                 @Nullable PersistableBundle templateParams,
207                 @Nullable String templateId) {
208             mTemplateParams = templateParams;
209             mTemplateId = templateId;
210         }
211 
212         /**
213          * The content to be rendered.
214          */
215         @DataClass.Generated.Member
setContent(@ndroid.annotation.NonNull String value)216         public @android.annotation.NonNull Builder setContent(@android.annotation.NonNull String value) {
217             checkNotUsed();
218             mBuilderFieldsSet |= 0x1;
219             mContent = value;
220             return this;
221         }
222 
223         /**
224          * Parameters for template rendering
225          */
226         @DataClass.Generated.Member
setTemplateParams(@ndroid.annotation.NonNull PersistableBundle value)227         public @android.annotation.NonNull Builder setTemplateParams(@android.annotation.NonNull PersistableBundle value) {
228             checkNotUsed();
229             mBuilderFieldsSet |= 0x2;
230             mTemplateParams = value;
231             return this;
232         }
233 
234         /**
235          * Template ID to retrieve from REMOTE_DATA for rendering
236          */
237         @DataClass.Generated.Member
setTemplateId(@ndroid.annotation.NonNull String value)238         public @android.annotation.NonNull Builder setTemplateId(@android.annotation.NonNull String value) {
239             checkNotUsed();
240             mBuilderFieldsSet |= 0x4;
241             mTemplateId = value;
242             return this;
243         }
244 
245         /** Builds the instance. This builder should not be touched after calling this! */
build()246         public @android.annotation.NonNull RenderOutput build() {
247             checkNotUsed();
248             mBuilderFieldsSet |= 0x8; // Mark builder used
249 
250             if ((mBuilderFieldsSet & 0x1) == 0) {
251                 mContent = "";
252             }
253             RenderOutput o = new RenderOutput(
254                     mContent,
255                     mTemplateParams,
256                     mTemplateId);
257             return o;
258         }
259 
checkNotUsed()260         private void checkNotUsed() {
261             if ((mBuilderFieldsSet & 0x8) != 0) {
262                 throw new IllegalStateException(
263                         "This Builder should not be reused. Use a new Builder instance instead");
264             }
265         }
266     }
267 
268     @DataClass.Generated(
269             time = 1680809171341L,
270             codegenVersion = "1.0.23",
271             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/RenderOutput.java",
272             inputSignatures = "private @android.annotation.Nullable java.lang.String mContent\nprivate @android.annotation.Nullable android.os.PersistableBundle mTemplateParams\nprivate @android.annotation.Nullable java.lang.String mTemplateId\nclass RenderOutput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
273     @Deprecated
__metadata()274     private void __metadata() {}
275 
276 
277     //@formatter:on
278     // End of generated code
279 
280 }
281