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