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 com.android.ondevicepersonalization.services.data.events; 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.io.Serializable; 26 27 /** 28 * Event object for the Events table 29 */ 30 @DataClass( 31 genBuilder = true, 32 genEqualsHashCode = true 33 ) 34 public class Event implements Serializable { 35 /** The id of the event. */ 36 private final long mEventId; 37 38 /** The id of the query. */ 39 private final long mQueryId; 40 41 /** Index of the slot for this event. */ 42 private final long mSlotIndex; 43 44 /** Id of the bidder for this event */ 45 @NonNull 46 private final String mBidId; 47 48 /** Name of the service package for this event */ 49 @NonNull 50 private final String mServicePackageName; 51 52 /** The position of the event in the slot */ 53 private final int mSlotPosition; 54 55 /** {@link EventType} defining the type of event */ 56 private final int mType; 57 58 /** Time of the event in milliseconds. */ 59 private final long mTimeMillis; 60 61 /** Id of the slot for this event */ 62 @Nullable 63 private final String mSlotId; 64 65 /** Blob representing the event. */ 66 @Nullable 67 private final byte[] mEventData; 68 69 70 71 // Code below generated by codegen v1.0.23. 72 // 73 // DO NOT MODIFY! 74 // CHECKSTYLE:OFF Generated code 75 // 76 // To regenerate run: 77 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Event.java 78 // 79 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 80 // Settings > Editor > Code Style > Formatter Control 81 //@formatter:off 82 83 84 @DataClass.Generated.Member Event( long eventId, long queryId, long slotIndex, @NonNull String bidId, @NonNull String servicePackageName, int slotPosition, int type, long timeMillis, @Nullable String slotId, @Nullable byte[] eventData)85 /* package-private */ Event( 86 long eventId, 87 long queryId, 88 long slotIndex, 89 @NonNull String bidId, 90 @NonNull String servicePackageName, 91 int slotPosition, 92 int type, 93 long timeMillis, 94 @Nullable String slotId, 95 @Nullable byte[] eventData) { 96 this.mEventId = eventId; 97 this.mQueryId = queryId; 98 this.mSlotIndex = slotIndex; 99 this.mBidId = bidId; 100 AnnotationValidations.validate( 101 NonNull.class, null, mBidId); 102 this.mServicePackageName = servicePackageName; 103 AnnotationValidations.validate( 104 NonNull.class, null, mServicePackageName); 105 this.mSlotPosition = slotPosition; 106 this.mType = type; 107 this.mTimeMillis = timeMillis; 108 this.mSlotId = slotId; 109 this.mEventData = eventData; 110 111 // onConstructed(); // You can define this method to get a callback 112 } 113 114 /** 115 * The id of the event. 116 */ 117 @DataClass.Generated.Member getEventId()118 public long getEventId() { 119 return mEventId; 120 } 121 122 /** 123 * The id of the query. 124 */ 125 @DataClass.Generated.Member getQueryId()126 public long getQueryId() { 127 return mQueryId; 128 } 129 130 /** 131 * Index of the slot for this event. 132 */ 133 @DataClass.Generated.Member getSlotIndex()134 public long getSlotIndex() { 135 return mSlotIndex; 136 } 137 138 /** 139 * Id of the bidder for this event 140 */ 141 @DataClass.Generated.Member getBidId()142 public @NonNull String getBidId() { 143 return mBidId; 144 } 145 146 /** 147 * Name of the service package for this event 148 */ 149 @DataClass.Generated.Member getServicePackageName()150 public @NonNull String getServicePackageName() { 151 return mServicePackageName; 152 } 153 154 /** 155 * The position of the event in the slot 156 */ 157 @DataClass.Generated.Member getSlotPosition()158 public int getSlotPosition() { 159 return mSlotPosition; 160 } 161 162 /** 163 * {@link EventType} defining the type of event 164 */ 165 @DataClass.Generated.Member getType()166 public int getType() { 167 return mType; 168 } 169 170 /** 171 * Time of the event in milliseconds. 172 */ 173 @DataClass.Generated.Member getTimeMillis()174 public long getTimeMillis() { 175 return mTimeMillis; 176 } 177 178 /** 179 * Id of the slot for this event 180 */ 181 @DataClass.Generated.Member getSlotId()182 public @Nullable String getSlotId() { 183 return mSlotId; 184 } 185 186 /** 187 * Blob representing the event. 188 */ 189 @DataClass.Generated.Member getEventData()190 public @Nullable byte[] getEventData() { 191 return mEventData; 192 } 193 194 @Override 195 @DataClass.Generated.Member equals(@ullable Object o)196 public boolean equals(@Nullable Object o) { 197 // You can override field equality logic by defining either of the methods like: 198 // boolean fieldNameEquals(Event other) { ... } 199 // boolean fieldNameEquals(FieldType otherValue) { ... } 200 201 if (this == o) return true; 202 if (o == null || getClass() != o.getClass()) return false; 203 @SuppressWarnings("unchecked") 204 Event that = (Event) o; 205 //noinspection PointlessBooleanExpression 206 return true 207 && mEventId == that.mEventId 208 && mQueryId == that.mQueryId 209 && mSlotIndex == that.mSlotIndex 210 && java.util.Objects.equals(mBidId, that.mBidId) 211 && java.util.Objects.equals(mServicePackageName, that.mServicePackageName) 212 && mSlotPosition == that.mSlotPosition 213 && mType == that.mType 214 && mTimeMillis == that.mTimeMillis 215 && java.util.Objects.equals(mSlotId, that.mSlotId) 216 && java.util.Arrays.equals(mEventData, that.mEventData); 217 } 218 219 @Override 220 @DataClass.Generated.Member hashCode()221 public int hashCode() { 222 // You can override field hashCode logic by defining methods like: 223 // int fieldNameHashCode() { ... } 224 225 int _hash = 1; 226 _hash = 31 * _hash + Long.hashCode(mEventId); 227 _hash = 31 * _hash + Long.hashCode(mQueryId); 228 _hash = 31 * _hash + Long.hashCode(mSlotIndex); 229 _hash = 31 * _hash + java.util.Objects.hashCode(mBidId); 230 _hash = 31 * _hash + java.util.Objects.hashCode(mServicePackageName); 231 _hash = 31 * _hash + mSlotPosition; 232 _hash = 31 * _hash + mType; 233 _hash = 31 * _hash + Long.hashCode(mTimeMillis); 234 _hash = 31 * _hash + java.util.Objects.hashCode(mSlotId); 235 _hash = 31 * _hash + java.util.Arrays.hashCode(mEventData); 236 return _hash; 237 } 238 239 /** 240 * A builder for {@link Event} 241 */ 242 @SuppressWarnings("WeakerAccess") 243 @DataClass.Generated.Member 244 public static class Builder { 245 246 private long mEventId; 247 private long mQueryId; 248 private long mSlotIndex; 249 private @NonNull String mBidId; 250 private @NonNull String mServicePackageName; 251 private int mSlotPosition; 252 private int mType; 253 private long mTimeMillis; 254 private @Nullable String mSlotId; 255 private @Nullable byte[] mEventData; 256 257 private long mBuilderFieldsSet = 0L; 258 Builder()259 public Builder() { 260 } 261 262 /** 263 * Creates a new Builder. 264 * 265 * @param eventId 266 * The id of the event. 267 * @param queryId 268 * The id of the query. 269 * @param slotIndex 270 * Index of the slot for this event. 271 * @param bidId 272 * Id of the bidder for this event 273 * @param servicePackageName 274 * Name of the service package for this event 275 * @param slotPosition 276 * The position of the event in the slot 277 * @param type 278 * {@link EventType} defining the type of event 279 * @param timeMillis 280 * Time of the event in milliseconds. 281 * @param slotId 282 * Id of the slot for this event 283 * @param eventData 284 * Blob representing the event. 285 */ Builder( long eventId, long queryId, long slotIndex, @NonNull String bidId, @NonNull String servicePackageName, int slotPosition, int type, long timeMillis, @Nullable String slotId, @Nullable byte[] eventData)286 public Builder( 287 long eventId, 288 long queryId, 289 long slotIndex, 290 @NonNull String bidId, 291 @NonNull String servicePackageName, 292 int slotPosition, 293 int type, 294 long timeMillis, 295 @Nullable String slotId, 296 @Nullable byte[] eventData) { 297 mEventId = eventId; 298 mQueryId = queryId; 299 mSlotIndex = slotIndex; 300 mBidId = bidId; 301 AnnotationValidations.validate( 302 NonNull.class, null, mBidId); 303 mServicePackageName = servicePackageName; 304 AnnotationValidations.validate( 305 NonNull.class, null, mServicePackageName); 306 mSlotPosition = slotPosition; 307 mType = type; 308 mTimeMillis = timeMillis; 309 mSlotId = slotId; 310 mEventData = eventData; 311 } 312 313 /** 314 * The id of the event. 315 */ 316 @DataClass.Generated.Member setEventId(long value)317 public @NonNull Builder setEventId(long value) { 318 checkNotUsed(); 319 mBuilderFieldsSet |= 0x1; 320 mEventId = value; 321 return this; 322 } 323 324 /** 325 * The id of the query. 326 */ 327 @DataClass.Generated.Member setQueryId(long value)328 public @NonNull Builder setQueryId(long value) { 329 checkNotUsed(); 330 mBuilderFieldsSet |= 0x2; 331 mQueryId = value; 332 return this; 333 } 334 335 /** 336 * Index of the slot for this event. 337 */ 338 @DataClass.Generated.Member setSlotIndex(long value)339 public @NonNull Builder setSlotIndex(long value) { 340 checkNotUsed(); 341 mBuilderFieldsSet |= 0x4; 342 mSlotIndex = value; 343 return this; 344 } 345 346 /** 347 * Id of the bidder for this event 348 */ 349 @DataClass.Generated.Member setBidId(@onNull String value)350 public @NonNull Builder setBidId(@NonNull String value) { 351 checkNotUsed(); 352 mBuilderFieldsSet |= 0x8; 353 mBidId = value; 354 return this; 355 } 356 357 /** 358 * Name of the service package for this event 359 */ 360 @DataClass.Generated.Member setServicePackageName(@onNull String value)361 public @NonNull Builder setServicePackageName(@NonNull String value) { 362 checkNotUsed(); 363 mBuilderFieldsSet |= 0x10; 364 mServicePackageName = value; 365 return this; 366 } 367 368 /** 369 * The position of the event in the slot 370 */ 371 @DataClass.Generated.Member setSlotPosition(int value)372 public @NonNull Builder setSlotPosition(int value) { 373 checkNotUsed(); 374 mBuilderFieldsSet |= 0x20; 375 mSlotPosition = value; 376 return this; 377 } 378 379 /** 380 * {@link EventType} defining the type of event 381 */ 382 @DataClass.Generated.Member setType(int value)383 public @NonNull Builder setType(int value) { 384 checkNotUsed(); 385 mBuilderFieldsSet |= 0x40; 386 mType = value; 387 return this; 388 } 389 390 /** 391 * Time of the event in milliseconds. 392 */ 393 @DataClass.Generated.Member setTimeMillis(long value)394 public @NonNull Builder setTimeMillis(long value) { 395 checkNotUsed(); 396 mBuilderFieldsSet |= 0x80; 397 mTimeMillis = value; 398 return this; 399 } 400 401 /** 402 * Id of the slot for this event 403 */ 404 @DataClass.Generated.Member setSlotId(@onNull String value)405 public @NonNull Builder setSlotId(@NonNull String value) { 406 checkNotUsed(); 407 mBuilderFieldsSet |= 0x100; 408 mSlotId = value; 409 return this; 410 } 411 412 /** 413 * Blob representing the event. 414 */ 415 @DataClass.Generated.Member setEventData(@onNull byte... value)416 public @NonNull Builder setEventData(@NonNull byte... value) { 417 checkNotUsed(); 418 mBuilderFieldsSet |= 0x200; 419 mEventData = value; 420 return this; 421 } 422 423 /** Builds the instance. This builder should not be touched after calling this! */ build()424 public @NonNull Event build() { 425 checkNotUsed(); 426 mBuilderFieldsSet |= 0x400; // Mark builder used 427 428 Event o = new Event( 429 mEventId, 430 mQueryId, 431 mSlotIndex, 432 mBidId, 433 mServicePackageName, 434 mSlotPosition, 435 mType, 436 mTimeMillis, 437 mSlotId, 438 mEventData); 439 return o; 440 } 441 checkNotUsed()442 private void checkNotUsed() { 443 if ((mBuilderFieldsSet & 0x400) != 0) { 444 throw new IllegalStateException( 445 "This Builder should not be reused. Use a new Builder instance instead"); 446 } 447 } 448 } 449 450 @DataClass.Generated( 451 time = 1679497934336L, 452 codegenVersion = "1.0.23", 453 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Event.java", 454 inputSignatures = "private final long mEventId\nprivate final long mQueryId\nprivate final long mSlotIndex\nprivate final @android.annotation.NonNull java.lang.String mBidId\nprivate final @android.annotation.NonNull java.lang.String mServicePackageName\nprivate final int mSlotPosition\nprivate final int mType\nprivate final long mTimeMillis\nprivate final @android.annotation.Nullable java.lang.String mSlotId\nprivate final @android.annotation.Nullable byte[] mEventData\nclass Event extends java.lang.Object implements [java.io.Serializable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 455 @Deprecated __metadata()456 private void __metadata() {} 457 458 459 //@formatter:on 460 // End of generated code 461 462 } 463