• 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.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcelable;
22 
23 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
24 import com.android.ondevicepersonalization.internal.util.DataClass;
25 
26 import java.util.List;
27 
28 /**
29  * The result for one of the slots in the request from a calling app.
30  *
31  * @hide
32  */
33 @DataClass(genBuilder = true, genEqualsHashCode = true)
34 public final class SlotResult implements Parcelable {
35     /**
36      * An identifier for this slot. Will be logged in the queries table and
37      * available for reporting. Must be a key in REMOTE_DATA.
38      */
39     @NonNull private String mSlotKey = "";
40 
41     /**
42      * A list of keys in the REMOTE_DATA table that represent bids to be rendered
43      * in this slot.
44      */
45     @Nullable private List<String> mRenderedBidKeys = null;
46     /**
47      * A list of bids with metrics to be logged in the QUERIES table.
48      */
49     @Nullable private List<Bid> mLoggedBids = null;
50 
51 
52 
53     // Code below generated by codegen v1.0.23.
54     //
55     // DO NOT MODIFY!
56     // CHECKSTYLE:OFF Generated code
57     //
58     // To regenerate run:
59     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/SlotResult.java
60     //
61     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
62     //   Settings > Editor > Code Style > Formatter Control
63     //@formatter:off
64 
65 
66     @DataClass.Generated.Member
SlotResult( @onNull String slotKey, @Nullable List<String> renderedBidKeys, @Nullable List<Bid> loggedBids)67     /* package-private */ SlotResult(
68             @NonNull String slotKey,
69             @Nullable List<String> renderedBidKeys,
70             @Nullable List<Bid> loggedBids) {
71         this.mSlotKey = slotKey;
72         AnnotationValidations.validate(
73                 NonNull.class, null, mSlotKey);
74         this.mRenderedBidKeys = renderedBidKeys;
75         this.mLoggedBids = loggedBids;
76 
77         // onConstructed(); // You can define this method to get a callback
78     }
79 
80     /**
81      * An identifier for this slot. Will be logged in the queries table and
82      * available for reporting. Must be a key in REMOTE_DATA.
83      */
84     @DataClass.Generated.Member
getSlotKey()85     public @NonNull String getSlotKey() {
86         return mSlotKey;
87     }
88 
89     /**
90      * A list of keys in the REMOTE_DATA table that represent bids to be rendered
91      * in this slot.
92      */
93     @DataClass.Generated.Member
getRenderedBidKeys()94     public @Nullable List<String> getRenderedBidKeys() {
95         return mRenderedBidKeys;
96     }
97 
98     /**
99      * A list of bids with metrics to be logged in the QUERIES table.
100      */
101     @DataClass.Generated.Member
getLoggedBids()102     public @Nullable List<Bid> getLoggedBids() {
103         return mLoggedBids;
104     }
105 
106     @Override
107     @DataClass.Generated.Member
equals(@ullable Object o)108     public boolean equals(@Nullable Object o) {
109         // You can override field equality logic by defining either of the methods like:
110         // boolean fieldNameEquals(SlotResult other) { ... }
111         // boolean fieldNameEquals(FieldType otherValue) { ... }
112 
113         if (this == o) return true;
114         if (o == null || getClass() != o.getClass()) return false;
115         @SuppressWarnings("unchecked")
116         SlotResult that = (SlotResult) o;
117         //noinspection PointlessBooleanExpression
118         return true
119                 && java.util.Objects.equals(mSlotKey, that.mSlotKey)
120                 && java.util.Objects.equals(mRenderedBidKeys, that.mRenderedBidKeys)
121                 && java.util.Objects.equals(mLoggedBids, that.mLoggedBids);
122     }
123 
124     @Override
125     @DataClass.Generated.Member
hashCode()126     public int hashCode() {
127         // You can override field hashCode logic by defining methods like:
128         // int fieldNameHashCode() { ... }
129 
130         int _hash = 1;
131         _hash = 31 * _hash + java.util.Objects.hashCode(mSlotKey);
132         _hash = 31 * _hash + java.util.Objects.hashCode(mRenderedBidKeys);
133         _hash = 31 * _hash + java.util.Objects.hashCode(mLoggedBids);
134         return _hash;
135     }
136 
137     @Override
138     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)139     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
140         // You can override field parcelling by defining methods like:
141         // void parcelFieldName(Parcel dest, int flags) { ... }
142 
143         byte flg = 0;
144         if (mRenderedBidKeys != null) flg |= 0x2;
145         if (mLoggedBids != null) flg |= 0x4;
146         dest.writeByte(flg);
147         dest.writeString(mSlotKey);
148         if (mRenderedBidKeys != null) dest.writeStringList(mRenderedBidKeys);
149         if (mLoggedBids != null) dest.writeParcelableList(mLoggedBids, flags);
150     }
151 
152     @Override
153     @DataClass.Generated.Member
describeContents()154     public int describeContents() { return 0; }
155 
156     /** @hide */
157     @SuppressWarnings({"unchecked", "RedundantCast"})
158     @DataClass.Generated.Member
SlotResult(@onNull android.os.Parcel in)159     /* package-private */ SlotResult(@NonNull android.os.Parcel in) {
160         // You can override field unparcelling by defining methods like:
161         // static FieldType unparcelFieldName(Parcel in) { ... }
162 
163         byte flg = in.readByte();
164         String slotKey = in.readString();
165         List<String> renderedBidKeys = null;
166         if ((flg & 0x2) != 0) {
167             renderedBidKeys = new java.util.ArrayList<>();
168             in.readStringList(renderedBidKeys);
169         }
170         List<Bid> loggedBids = null;
171         if ((flg & 0x4) != 0) {
172             loggedBids = new java.util.ArrayList<>();
173             in.readParcelableList(loggedBids, Bid.class.getClassLoader());
174         }
175 
176         this.mSlotKey = slotKey;
177         AnnotationValidations.validate(
178                 NonNull.class, null, mSlotKey);
179         this.mRenderedBidKeys = renderedBidKeys;
180         this.mLoggedBids = loggedBids;
181 
182         // onConstructed(); // You can define this method to get a callback
183     }
184 
185     @DataClass.Generated.Member
186     public static final @NonNull Parcelable.Creator<SlotResult> CREATOR
187             = new Parcelable.Creator<SlotResult>() {
188         @Override
189         public SlotResult[] newArray(int size) {
190             return new SlotResult[size];
191         }
192 
193         @Override
194         public SlotResult createFromParcel(@NonNull android.os.Parcel in) {
195             return new SlotResult(in);
196         }
197     };
198 
199     /**
200      * A builder for {@link SlotResult}
201      */
202     @SuppressWarnings("WeakerAccess")
203     @DataClass.Generated.Member
204     public static final class Builder {
205 
206         private @NonNull String mSlotKey;
207         private @Nullable List<String> mRenderedBidKeys;
208         private @Nullable List<Bid> mLoggedBids;
209 
210         private long mBuilderFieldsSet = 0L;
211 
Builder()212         public Builder() {
213         }
214 
215         /**
216          * An identifier for this slot. Will be logged in the queries table and
217          * available for reporting. Must be a key in REMOTE_DATA.
218          */
219         @DataClass.Generated.Member
setSlotKey(@onNull String value)220         public @NonNull Builder setSlotKey(@NonNull String value) {
221             checkNotUsed();
222             mBuilderFieldsSet |= 0x1;
223             mSlotKey = value;
224             return this;
225         }
226 
227         /**
228          * A list of keys in the REMOTE_DATA table that represent bids to be rendered
229          * in this slot.
230          */
231         @DataClass.Generated.Member
setRenderedBidKeys(@onNull List<String> value)232         public @NonNull Builder setRenderedBidKeys(@NonNull List<String> value) {
233             checkNotUsed();
234             mBuilderFieldsSet |= 0x2;
235             mRenderedBidKeys = value;
236             return this;
237         }
238 
239         /** @see #setRenderedBidKeys */
240         @DataClass.Generated.Member
addRenderedBidKeys(@onNull String value)241         public @NonNull Builder addRenderedBidKeys(@NonNull String value) {
242             // You can refine this method's name by providing item's singular name, e.g.:
243             // @DataClass.PluralOf("item")) mItems = ...
244 
245             if (mRenderedBidKeys == null) setRenderedBidKeys(new java.util.ArrayList<>());
246             mRenderedBidKeys.add(value);
247             return this;
248         }
249 
250         /**
251          * A list of bids with metrics to be logged in the QUERIES table.
252          */
253         @DataClass.Generated.Member
setLoggedBids(@onNull List<Bid> value)254         public @NonNull Builder setLoggedBids(@NonNull List<Bid> value) {
255             checkNotUsed();
256             mBuilderFieldsSet |= 0x4;
257             mLoggedBids = value;
258             return this;
259         }
260 
261         /** @see #setLoggedBids */
262         @DataClass.Generated.Member
addLoggedBids(@onNull Bid value)263         public @NonNull Builder addLoggedBids(@NonNull Bid value) {
264             // You can refine this method's name by providing item's singular name, e.g.:
265             // @DataClass.PluralOf("item")) mItems = ...
266 
267             if (mLoggedBids == null) setLoggedBids(new java.util.ArrayList<>());
268             mLoggedBids.add(value);
269             return this;
270         }
271 
272         /** Builds the instance. This builder should not be touched after calling this! */
build()273         public @NonNull SlotResult build() {
274             checkNotUsed();
275             mBuilderFieldsSet |= 0x8; // Mark builder used
276 
277             if ((mBuilderFieldsSet & 0x1) == 0) {
278                 mSlotKey = "";
279             }
280             if ((mBuilderFieldsSet & 0x2) == 0) {
281                 mRenderedBidKeys = null;
282             }
283             if ((mBuilderFieldsSet & 0x4) == 0) {
284                 mLoggedBids = null;
285             }
286             SlotResult o = new SlotResult(
287                     mSlotKey,
288                     mRenderedBidKeys,
289                     mLoggedBids);
290             return o;
291         }
292 
checkNotUsed()293         private void checkNotUsed() {
294             if ((mBuilderFieldsSet & 0x8) != 0) {
295                 throw new IllegalStateException(
296                         "This Builder should not be reused. Use a new Builder instance instead");
297             }
298         }
299     }
300 
301     @DataClass.Generated(
302             time = 1681847760091L,
303             codegenVersion = "1.0.23",
304             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/SlotResult.java",
305             inputSignatures = "private @android.annotation.NonNull java.lang.String mSlotKey\nprivate @android.annotation.Nullable java.util.List<java.lang.String> mRenderedBidKeys\nprivate @android.annotation.Nullable java.util.List<android.ondevicepersonalization.Bid> mLoggedBids\nclass SlotResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
306     @Deprecated
__metadata()307     private void __metadata() {}
308 
309 
310     //@formatter:on
311     // End of generated code
312 
313 }
314