• 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.adservices.ondevicepersonalization;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 
22 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
23 import com.android.ondevicepersonalization.internal.util.DataClass;
24 
25 import java.util.Collections;
26 import java.util.List;
27 
28 /**
29  * The result that should be returned by
30  * {@link IsolatedWorker#onWebTrigger(WebTriggerInput, android.os.OutcomeReceiver)}.
31  * This class contains data that should be written to the REQUESTS or EVENTS tables.
32  * The contents of these tables can be consumed by Federated Learning facilitated model training,
33  * or Federated Analytics facilitated cross-device statistical analysis.
34  */
35 @DataClass(genBuilder = true, genEqualsHashCode = true)
36 public final class WebTriggerOutput {
37     /**
38      * Persistent data to be written to the REQUESTS table after
39      * {@link IsolatedWorker#onWebTrigger(WebTriggerInput, android.os.OutcomeReceiver)}
40      * completes. This can be {@code null} if no data needs to be written to
41      * the REQUESTS table.
42      */
43     @DataClass.MaySetToNull
44     @Nullable private RequestLogRecord mRequestLogRecord = null;
45 
46     /**
47      * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each
48      * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in
49      * the REQUESTS table, specified using
50      * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}.
51      * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be
52      * written. The list can be empty if no data needs to be written to the EVENTS table.
53      */
54     @DataClass.PluralOf("eventLogRecord")
55     @NonNull private List<EventLogRecord> mEventLogRecords = Collections.emptyList();
56 
57 
58 
59     // Code below generated by codegen v1.0.23.
60     //
61     // DO NOT MODIFY!
62     // CHECKSTYLE:OFF Generated code
63     //
64     // To regenerate run:
65     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/WebTriggerOutput.java
66     //
67     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
68     //   Settings > Editor > Code Style > Formatter Control
69     //@formatter:off
70 
71 
72     @DataClass.Generated.Member
WebTriggerOutput( @ullable RequestLogRecord requestLogRecord, @NonNull List<EventLogRecord> eventLogRecords)73     /* package-private */ WebTriggerOutput(
74             @Nullable RequestLogRecord requestLogRecord,
75             @NonNull List<EventLogRecord> eventLogRecords) {
76         this.mRequestLogRecord = requestLogRecord;
77         this.mEventLogRecords = eventLogRecords;
78         AnnotationValidations.validate(
79                 NonNull.class, null, mEventLogRecords);
80 
81         // onConstructed(); // You can define this method to get a callback
82     }
83 
84     /**
85      * Persistent data to be written to the REQUESTS table after
86      * {@link IsolatedWorker#onWebTrigger(WebTriggerInput, android.os.OutcomeReceiver)}
87      * completes. This can be {@code null} if no data needs to be written to
88      * the REQUESTS table.
89      */
90     @DataClass.Generated.Member
getRequestLogRecord()91     public @Nullable RequestLogRecord getRequestLogRecord() {
92         return mRequestLogRecord;
93     }
94 
95     /**
96      * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each
97      * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in
98      * the REQUESTS table, specified using
99      * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}.
100      * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be
101      * written. The list can be empty if no data needs to be written to the EVENTS table.
102      */
103     @DataClass.Generated.Member
getEventLogRecords()104     public @NonNull List<EventLogRecord> getEventLogRecords() {
105         return mEventLogRecords;
106     }
107 
108     @Override
109     @DataClass.Generated.Member
equals(@ullable Object o)110     public boolean equals(@Nullable Object o) {
111         // You can override field equality logic by defining either of the methods like:
112         // boolean fieldNameEquals(WebTriggerOutput other) { ... }
113         // boolean fieldNameEquals(FieldType otherValue) { ... }
114 
115         if (this == o) return true;
116         if (o == null || getClass() != o.getClass()) return false;
117         @SuppressWarnings("unchecked")
118         WebTriggerOutput that = (WebTriggerOutput) o;
119         //noinspection PointlessBooleanExpression
120         return true
121                 && java.util.Objects.equals(mRequestLogRecord, that.mRequestLogRecord)
122                 && java.util.Objects.equals(mEventLogRecords, that.mEventLogRecords);
123     }
124 
125     @Override
126     @DataClass.Generated.Member
hashCode()127     public int hashCode() {
128         // You can override field hashCode logic by defining methods like:
129         // int fieldNameHashCode() { ... }
130 
131         int _hash = 1;
132         _hash = 31 * _hash + java.util.Objects.hashCode(mRequestLogRecord);
133         _hash = 31 * _hash + java.util.Objects.hashCode(mEventLogRecords);
134         return _hash;
135     }
136 
137     /**
138      * A builder for {@link WebTriggerOutput}
139      */
140     @SuppressWarnings("WeakerAccess")
141     @DataClass.Generated.Member
142     public static final class Builder {
143 
144         private @Nullable RequestLogRecord mRequestLogRecord;
145         private @NonNull List<EventLogRecord> mEventLogRecords;
146 
147         private long mBuilderFieldsSet = 0L;
148 
Builder()149         public Builder() {
150         }
151 
152         /**
153          * Persistent data to be written to the REQUESTS table after
154          * {@link IsolatedWorker#onWebTrigger(WebTriggerInput, android.os.OutcomeReceiver)}
155          * completes. This can be {@code null} if no data needs to be written to
156          * the REQUESTS table.
157          */
158         @DataClass.Generated.Member
setRequestLogRecord(@ullable RequestLogRecord value)159         public @NonNull Builder setRequestLogRecord(@Nullable RequestLogRecord value) {
160             checkNotUsed();
161             mBuilderFieldsSet |= 0x1;
162             mRequestLogRecord = value;
163             return this;
164         }
165 
166         /**
167          * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each
168          * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in
169          * the REQUESTS table, specified using
170          * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}.
171          * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be
172          * written. The list can be empty if no data needs to be written to the EVENTS table.
173          */
174         @DataClass.Generated.Member
setEventLogRecords(@onNull List<EventLogRecord> value)175         public @NonNull Builder setEventLogRecords(@NonNull List<EventLogRecord> value) {
176             checkNotUsed();
177             mBuilderFieldsSet |= 0x2;
178             mEventLogRecords = value;
179             return this;
180         }
181 
182         /** @see #setEventLogRecords */
183         @DataClass.Generated.Member
addEventLogRecord(@onNull EventLogRecord value)184         public @NonNull Builder addEventLogRecord(@NonNull EventLogRecord value) {
185             if (mEventLogRecords == null) setEventLogRecords(new java.util.ArrayList<>());
186             mEventLogRecords.add(value);
187             return this;
188         }
189 
190         /** Builds the instance. This builder should not be touched after calling this! */
build()191         public @NonNull WebTriggerOutput build() {
192             checkNotUsed();
193             mBuilderFieldsSet |= 0x4; // Mark builder used
194 
195             if ((mBuilderFieldsSet & 0x1) == 0) {
196                 mRequestLogRecord = null;
197             }
198             if ((mBuilderFieldsSet & 0x2) == 0) {
199                 mEventLogRecords = Collections.emptyList();
200             }
201             WebTriggerOutput o = new WebTriggerOutput(
202                     mRequestLogRecord,
203                     mEventLogRecords);
204             return o;
205         }
206 
checkNotUsed()207         private void checkNotUsed() {
208             if ((mBuilderFieldsSet & 0x4) != 0) {
209                 throw new IllegalStateException(
210                         "This Builder should not be reused. Use a new Builder instance instead");
211             }
212         }
213     }
214 
215     @DataClass.Generated(
216             time = 1707251898683L,
217             codegenVersion = "1.0.23",
218             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/WebTriggerOutput.java",
219             inputSignatures = "private @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable android.adservices.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @com.android.ondevicepersonalization.internal.util.DataClass.PluralOf(\"eventLogRecord\") @android.annotation.NonNull java.util.List<android.adservices.ondevicepersonalization.EventLogRecord> mEventLogRecords\nclass WebTriggerOutput extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
220     @Deprecated
__metadata()221     private void __metadata() {}
222 
223 
224     //@formatter:on
225     // End of generated code
226 
227 }
228