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.adservices.ondevicepersonalization;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.os.Parcelable;
22 
23 import com.android.adservices.ondevicepersonalization.flags.Flags;
24 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
25 import com.android.ondevicepersonalization.internal.util.DataClass;
26 
27 import java.util.Collections;
28 import java.util.List;
29 
30 /**
31  * Information returned by
32  * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}
33  * that is used in a subesequent call to
34  * {@link IsolatedWorker#onRender(RenderInput, android.os.OutcomeReceiver)} to identify the
35  * content to be displayed in a single {@link android.view.View}.
36  *
37  */
38 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED)
39 @DataClass(genBuilder = true, genEqualsHashCode = true)
40 public final class RenderingConfig implements Parcelable {
41     /**
42      * A List of keys in the REMOTE_DATA
43      * {@link IsolatedService#getRemoteData(RequestToken)}
44      * table that identify the content to be rendered.
45      **/
46     @DataClass.PluralOf("key")
47     @NonNull private List<String> mKeys = Collections.emptyList();
48 
49 
50 
51     // Code below generated by codegen v1.0.23.
52     //
53     // DO NOT MODIFY!
54     // CHECKSTYLE:OFF Generated code
55     //
56     // To regenerate run:
57     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/RenderingConfig.java
58     //
59     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
60     //   Settings > Editor > Code Style > Formatter Control
61     //@formatter:off
62 
63 
64     @DataClass.Generated.Member
RenderingConfig( @onNull List<String> keys)65     /* package-private */ RenderingConfig(
66             @NonNull List<String> keys) {
67         this.mKeys = keys;
68         AnnotationValidations.validate(
69                 NonNull.class, null, mKeys);
70 
71         // onConstructed(); // You can define this method to get a callback
72     }
73 
74     /**
75      * A List of keys in the REMOTE_DATA
76      * {@link IsolatedService#getRemoteData(RequestToken)}
77      * table that identify the content to be rendered.
78      */
79     @DataClass.Generated.Member
getKeys()80     public @NonNull List<String> getKeys() {
81         return mKeys;
82     }
83 
84     @Override
85     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)86     public boolean equals(@android.annotation.Nullable Object o) {
87         // You can override field equality logic by defining either of the methods like:
88         // boolean fieldNameEquals(RenderingConfig other) { ... }
89         // boolean fieldNameEquals(FieldType otherValue) { ... }
90 
91         if (this == o) return true;
92         if (o == null || getClass() != o.getClass()) return false;
93         @SuppressWarnings("unchecked")
94         RenderingConfig that = (RenderingConfig) o;
95         //noinspection PointlessBooleanExpression
96         return true
97                 && java.util.Objects.equals(mKeys, that.mKeys);
98     }
99 
100     @Override
101     @DataClass.Generated.Member
hashCode()102     public int hashCode() {
103         // You can override field hashCode logic by defining methods like:
104         // int fieldNameHashCode() { ... }
105 
106         int _hash = 1;
107         _hash = 31 * _hash + java.util.Objects.hashCode(mKeys);
108         return _hash;
109     }
110 
111     @Override
112     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)113     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
114         // You can override field parcelling by defining methods like:
115         // void parcelFieldName(Parcel dest, int flags) { ... }
116 
117         dest.writeStringList(mKeys);
118     }
119 
120     @Override
121     @DataClass.Generated.Member
describeContents()122     public int describeContents() { return 0; }
123 
124     /** @hide */
125     @SuppressWarnings({"unchecked", "RedundantCast"})
126     @DataClass.Generated.Member
RenderingConfig(@onNull android.os.Parcel in)127     /* package-private */ RenderingConfig(@NonNull android.os.Parcel in) {
128         // You can override field unparcelling by defining methods like:
129         // static FieldType unparcelFieldName(Parcel in) { ... }
130 
131         List<String> keys = new java.util.ArrayList<>();
132         in.readStringList(keys);
133 
134         this.mKeys = keys;
135         AnnotationValidations.validate(
136                 NonNull.class, null, mKeys);
137 
138         // onConstructed(); // You can define this method to get a callback
139     }
140 
141     @DataClass.Generated.Member
142     public static final @NonNull Parcelable.Creator<RenderingConfig> CREATOR
143             = new Parcelable.Creator<RenderingConfig>() {
144         @Override
145         public RenderingConfig[] newArray(int size) {
146             return new RenderingConfig[size];
147         }
148 
149         @Override
150         public RenderingConfig createFromParcel(@NonNull android.os.Parcel in) {
151             return new RenderingConfig(in);
152         }
153     };
154 
155     /**
156      * A builder for {@link RenderingConfig}
157      */
158     @SuppressWarnings("WeakerAccess")
159     @DataClass.Generated.Member
160     public static final class Builder {
161 
162         private @NonNull List<String> mKeys;
163 
164         private long mBuilderFieldsSet = 0L;
165 
Builder()166         public Builder() {
167         }
168 
169         /**
170          * A List of keys in the REMOTE_DATA
171          * {@link IsolatedService#getRemoteData(RequestToken)}
172          * table that identify the content to be rendered.
173          */
174         @DataClass.Generated.Member
setKeys(@onNull List<String> value)175         public @NonNull Builder setKeys(@NonNull List<String> value) {
176             checkNotUsed();
177             mBuilderFieldsSet |= 0x1;
178             mKeys = value;
179             return this;
180         }
181 
182         /** @see #setKeys */
183         @DataClass.Generated.Member
addKey(@onNull String value)184         public @NonNull Builder addKey(@NonNull String value) {
185             if (mKeys == null) setKeys(new java.util.ArrayList<>());
186             mKeys.add(value);
187             return this;
188         }
189 
190         /** Builds the instance. This builder should not be touched after calling this! */
build()191         public @NonNull RenderingConfig build() {
192             checkNotUsed();
193             mBuilderFieldsSet |= 0x2; // Mark builder used
194 
195             if ((mBuilderFieldsSet & 0x1) == 0) {
196                 mKeys = Collections.emptyList();
197             }
198             RenderingConfig o = new RenderingConfig(
199                     mKeys);
200             return o;
201         }
202 
checkNotUsed()203         private void checkNotUsed() {
204             if ((mBuilderFieldsSet & 0x2) != 0) {
205                 throw new IllegalStateException(
206                         "This Builder should not be reused. Use a new Builder instance instead");
207             }
208         }
209     }
210 
211     @DataClass.Generated(
212             time = 1697132616124L,
213             codegenVersion = "1.0.23",
214             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/RenderingConfig.java",
215             inputSignatures = "private @com.android.ondevicepersonalization.internal.util.DataClass.PluralOf(\"key\") @android.annotation.NonNull java.util.List<java.lang.String> mKeys\nclass RenderingConfig extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
216     @Deprecated
__metadata()217     private void __metadata() {}
218 
219 
220     //@formatter:on
221     // End of generated code
222 
223 }
224