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 
22 import com.android.adservices.ondevicepersonalization.flags.Flags;
23 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
24 import com.android.ondevicepersonalization.internal.util.DataClass;
25 
26 import java.util.Collections;
27 import java.util.List;
28 
29 /**
30  * The result returned by {@link
31  * IsolatedWorker#onDownloadCompleted(DownloadCompletedInput, android.os.OutcomeReceiver)}.
32  *
33  */
34 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED)
35 @DataClass(genBuilder = true, genEqualsHashCode = true)
36 public final class DownloadCompletedOutput {
37     /**
38      * The keys to be retained in the REMOTE_DATA table. Any existing keys that are not
39      * present in this list are removed from the table.
40      */
41     @DataClass.PluralOf("retainedKey")
42     @NonNull private List<String> mRetainedKeys = Collections.emptyList();
43 
44 
45 
46     // Code below generated by codegen v1.0.23.
47     //
48     // DO NOT MODIFY!
49     // CHECKSTYLE:OFF Generated code
50     //
51     // To regenerate run:
52     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/DownloadCompletedOutput.java
53     //
54     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
55     //   Settings > Editor > Code Style > Formatter Control
56     //@formatter:off
57 
58 
59     @DataClass.Generated.Member
DownloadCompletedOutput( @onNull List<String> retainedKeys)60     /* package-private */ DownloadCompletedOutput(
61             @NonNull List<String> retainedKeys) {
62         this.mRetainedKeys = retainedKeys;
63         AnnotationValidations.validate(
64                 NonNull.class, null, mRetainedKeys);
65 
66         // onConstructed(); // You can define this method to get a callback
67     }
68 
69     /**
70      * The keys to be retained in the REMOTE_DATA table. Any existing keys that are not
71      * present in this list are removed from the table.
72      */
73     @DataClass.Generated.Member
getRetainedKeys()74     public @NonNull List<String> getRetainedKeys() {
75         return mRetainedKeys;
76     }
77 
78     @Override
79     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)80     public boolean equals(@android.annotation.Nullable Object o) {
81         // You can override field equality logic by defining either of the methods like:
82         // boolean fieldNameEquals(DownloadCompletedOutput other) { ... }
83         // boolean fieldNameEquals(FieldType otherValue) { ... }
84 
85         if (this == o) return true;
86         if (o == null || getClass() != o.getClass()) return false;
87         @SuppressWarnings("unchecked")
88         DownloadCompletedOutput that = (DownloadCompletedOutput) o;
89         //noinspection PointlessBooleanExpression
90         return true
91                 && java.util.Objects.equals(mRetainedKeys, that.mRetainedKeys);
92     }
93 
94     @Override
95     @DataClass.Generated.Member
hashCode()96     public int hashCode() {
97         // You can override field hashCode logic by defining methods like:
98         // int fieldNameHashCode() { ... }
99 
100         int _hash = 1;
101         _hash = 31 * _hash + java.util.Objects.hashCode(mRetainedKeys);
102         return _hash;
103     }
104 
105     /**
106      * A builder for {@link DownloadCompletedOutput}
107      */
108     @SuppressWarnings("WeakerAccess")
109     @DataClass.Generated.Member
110     public static final class Builder {
111 
112         private @NonNull List<String> mRetainedKeys;
113 
114         private long mBuilderFieldsSet = 0L;
115 
Builder()116         public Builder() {
117         }
118 
119         /**
120          * The keys to be retained in the REMOTE_DATA table. Any existing keys that are not
121          * present in this list are removed from the table.
122          */
123         @DataClass.Generated.Member
setRetainedKeys(@onNull List<String> value)124         public @NonNull Builder setRetainedKeys(@NonNull List<String> value) {
125             checkNotUsed();
126             mBuilderFieldsSet |= 0x1;
127             mRetainedKeys = value;
128             return this;
129         }
130 
131         /** @see #setRetainedKeys */
132         @DataClass.Generated.Member
addRetainedKey(@onNull String value)133         public @NonNull Builder addRetainedKey(@NonNull String value) {
134             if (mRetainedKeys == null) setRetainedKeys(new java.util.ArrayList<>());
135             mRetainedKeys.add(value);
136             return this;
137         }
138 
139         /** Builds the instance. This builder should not be touched after calling this! */
build()140         public @NonNull DownloadCompletedOutput build() {
141             checkNotUsed();
142             mBuilderFieldsSet |= 0x2; // Mark builder used
143 
144             if ((mBuilderFieldsSet & 0x1) == 0) {
145                 mRetainedKeys = Collections.emptyList();
146             }
147             DownloadCompletedOutput o = new DownloadCompletedOutput(
148                     mRetainedKeys);
149             return o;
150         }
151 
checkNotUsed()152         private void checkNotUsed() {
153             if ((mBuilderFieldsSet & 0x2) != 0) {
154                 throw new IllegalStateException(
155                         "This Builder should not be reused. Use a new Builder instance instead");
156             }
157         }
158     }
159 
160     @DataClass.Generated(
161             time = 1698862918590L,
162             codegenVersion = "1.0.23",
163             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/DownloadCompletedOutput.java",
164             inputSignatures = "private @com.android.ondevicepersonalization.internal.util.DataClass.PluralOf(\"retainedKey\") @android.annotation.NonNull java.util.List<java.lang.String> mRetainedKeys\nclass DownloadCompletedOutput extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
165     @Deprecated
__metadata()166     private void __metadata() {}
167 
168 
169     //@formatter:on
170     // End of generated code
171 
172 }
173