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 import android.content.ComponentName; 22 23 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 24 import com.android.ondevicepersonalization.internal.util.DataClass; 25 import com.android.ondevicepersonalization.services.data.DbUtils; 26 27 import java.io.Serializable; 28 29 /** 30 * Event object for the Events table 31 */ 32 @DataClass( 33 genBuilder = true, 34 genEqualsHashCode = true 35 ) 36 public class Event implements Serializable { 37 /** The id of the event. */ 38 private final long mEventId; 39 40 /** The id of the query. */ 41 private final long mQueryId; 42 43 /** Index of the associated entry in the request log for this event. */ 44 private final int mRowIndex; 45 46 /** Name of the service for this event */ 47 @NonNull 48 private final ComponentName mService; 49 50 /** The service assigned type of the event. */ 51 private final int mType; 52 53 /** Time of the event in milliseconds. */ 54 private final long mTimeMillis; 55 56 /** Blob representing the event. */ 57 @Nullable 58 private final byte[] mEventData; 59 60 /** The name of the service */ getServiceName()61 public String getServiceName() { 62 return DbUtils.toTableValue(mService); 63 } 64 65 66 67 // Code below generated by codegen v1.0.23. 68 // 69 // DO NOT MODIFY! 70 // CHECKSTYLE:OFF Generated code 71 // 72 // To regenerate run: 73 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Event.java 74 // 75 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 76 // Settings > Editor > Code Style > Formatter Control 77 //@formatter:off 78 79 80 @DataClass.Generated.Member Event( long eventId, long queryId, int rowIndex, @NonNull ComponentName service, int type, long timeMillis, @Nullable byte[] eventData)81 /* package-private */ Event( 82 long eventId, 83 long queryId, 84 int rowIndex, 85 @NonNull ComponentName service, 86 int type, 87 long timeMillis, 88 @Nullable byte[] eventData) { 89 this.mEventId = eventId; 90 this.mQueryId = queryId; 91 this.mRowIndex = rowIndex; 92 this.mService = service; 93 AnnotationValidations.validate( 94 NonNull.class, null, mService); 95 this.mType = type; 96 this.mTimeMillis = timeMillis; 97 this.mEventData = eventData; 98 99 // onConstructed(); // You can define this method to get a callback 100 } 101 102 /** 103 * The id of the event. 104 */ 105 @DataClass.Generated.Member getEventId()106 public long getEventId() { 107 return mEventId; 108 } 109 110 /** 111 * The id of the query. 112 */ 113 @DataClass.Generated.Member getQueryId()114 public long getQueryId() { 115 return mQueryId; 116 } 117 118 /** 119 * Index of the associated entry in the request log for this event. 120 */ 121 @DataClass.Generated.Member getRowIndex()122 public int getRowIndex() { 123 return mRowIndex; 124 } 125 126 /** 127 * Name of the service for this event 128 */ 129 @DataClass.Generated.Member getService()130 public @NonNull ComponentName getService() { 131 return mService; 132 } 133 134 /** 135 * The service assigned type of the event. 136 */ 137 @DataClass.Generated.Member getType()138 public int getType() { 139 return mType; 140 } 141 142 /** 143 * Time of the event in milliseconds. 144 */ 145 @DataClass.Generated.Member getTimeMillis()146 public long getTimeMillis() { 147 return mTimeMillis; 148 } 149 150 /** 151 * Blob representing the event. 152 */ 153 @DataClass.Generated.Member getEventData()154 public @Nullable byte[] getEventData() { 155 return mEventData; 156 } 157 158 @Override 159 @DataClass.Generated.Member equals(@ullable Object o)160 public boolean equals(@Nullable Object o) { 161 // You can override field equality logic by defining either of the methods like: 162 // boolean fieldNameEquals(Event other) { ... } 163 // boolean fieldNameEquals(FieldType otherValue) { ... } 164 165 if (this == o) return true; 166 if (o == null || getClass() != o.getClass()) return false; 167 @SuppressWarnings("unchecked") 168 Event that = (Event) o; 169 //noinspection PointlessBooleanExpression 170 return true 171 && mEventId == that.mEventId 172 && mQueryId == that.mQueryId 173 && mRowIndex == that.mRowIndex 174 && java.util.Objects.equals(mService, that.mService) 175 && mType == that.mType 176 && mTimeMillis == that.mTimeMillis 177 && java.util.Arrays.equals(mEventData, that.mEventData); 178 } 179 180 @Override 181 @DataClass.Generated.Member hashCode()182 public int hashCode() { 183 // You can override field hashCode logic by defining methods like: 184 // int fieldNameHashCode() { ... } 185 186 int _hash = 1; 187 _hash = 31 * _hash + Long.hashCode(mEventId); 188 _hash = 31 * _hash + Long.hashCode(mQueryId); 189 _hash = 31 * _hash + mRowIndex; 190 _hash = 31 * _hash + java.util.Objects.hashCode(mService); 191 _hash = 31 * _hash + mType; 192 _hash = 31 * _hash + Long.hashCode(mTimeMillis); 193 _hash = 31 * _hash + java.util.Arrays.hashCode(mEventData); 194 return _hash; 195 } 196 197 /** 198 * A builder for {@link Event} 199 */ 200 @SuppressWarnings("WeakerAccess") 201 @DataClass.Generated.Member 202 public static class Builder { 203 204 private long mEventId; 205 private long mQueryId; 206 private int mRowIndex; 207 private @NonNull ComponentName mService; 208 private int mType; 209 private long mTimeMillis; 210 private @Nullable byte[] mEventData; 211 212 private long mBuilderFieldsSet = 0L; 213 Builder()214 public Builder() { 215 } 216 217 /** 218 * Creates a new Builder. 219 * 220 * @param eventId 221 * The id of the event. 222 * @param queryId 223 * The id of the query. 224 * @param rowIndex 225 * Index of the associated entry in the request log for this event. 226 * @param service 227 * Name of the service for this event 228 * @param type 229 * The service assigned type of the event. 230 * @param timeMillis 231 * Time of the event in milliseconds. 232 * @param eventData 233 * Blob representing the event. 234 */ Builder( long eventId, long queryId, int rowIndex, @NonNull ComponentName service, int type, long timeMillis, @Nullable byte[] eventData)235 public Builder( 236 long eventId, 237 long queryId, 238 int rowIndex, 239 @NonNull ComponentName service, 240 int type, 241 long timeMillis, 242 @Nullable byte[] eventData) { 243 mEventId = eventId; 244 mQueryId = queryId; 245 mRowIndex = rowIndex; 246 mService = service; 247 AnnotationValidations.validate( 248 NonNull.class, null, mService); 249 mType = type; 250 mTimeMillis = timeMillis; 251 mEventData = eventData; 252 } 253 254 /** 255 * The id of the event. 256 */ 257 @DataClass.Generated.Member setEventId(long value)258 public @NonNull Builder setEventId(long value) { 259 checkNotUsed(); 260 mBuilderFieldsSet |= 0x1; 261 mEventId = value; 262 return this; 263 } 264 265 /** 266 * The id of the query. 267 */ 268 @DataClass.Generated.Member setQueryId(long value)269 public @NonNull Builder setQueryId(long value) { 270 checkNotUsed(); 271 mBuilderFieldsSet |= 0x2; 272 mQueryId = value; 273 return this; 274 } 275 276 /** 277 * Index of the associated entry in the request log for this event. 278 */ 279 @DataClass.Generated.Member setRowIndex(int value)280 public @NonNull Builder setRowIndex(int value) { 281 checkNotUsed(); 282 mBuilderFieldsSet |= 0x4; 283 mRowIndex = value; 284 return this; 285 } 286 287 /** 288 * Name of the service for this event 289 */ 290 @DataClass.Generated.Member setService(@onNull ComponentName value)291 public @NonNull Builder setService(@NonNull ComponentName value) { 292 checkNotUsed(); 293 mBuilderFieldsSet |= 0x8; 294 mService = value; 295 return this; 296 } 297 298 /** 299 * The service assigned type of the event. 300 */ 301 @DataClass.Generated.Member setType(int value)302 public @NonNull Builder setType(int value) { 303 checkNotUsed(); 304 mBuilderFieldsSet |= 0x10; 305 mType = value; 306 return this; 307 } 308 309 /** 310 * Time of the event in milliseconds. 311 */ 312 @DataClass.Generated.Member setTimeMillis(long value)313 public @NonNull Builder setTimeMillis(long value) { 314 checkNotUsed(); 315 mBuilderFieldsSet |= 0x20; 316 mTimeMillis = value; 317 return this; 318 } 319 320 /** 321 * Blob representing the event. 322 */ 323 @DataClass.Generated.Member setEventData(@onNull byte... value)324 public @NonNull Builder setEventData(@NonNull byte... value) { 325 checkNotUsed(); 326 mBuilderFieldsSet |= 0x40; 327 mEventData = value; 328 return this; 329 } 330 331 /** Builds the instance. This builder should not be touched after calling this! */ build()332 public @NonNull Event build() { 333 checkNotUsed(); 334 mBuilderFieldsSet |= 0x80; // Mark builder used 335 336 Event o = new Event( 337 mEventId, 338 mQueryId, 339 mRowIndex, 340 mService, 341 mType, 342 mTimeMillis, 343 mEventData); 344 return o; 345 } 346 checkNotUsed()347 private void checkNotUsed() { 348 if ((mBuilderFieldsSet & 0x80) != 0) { 349 throw new IllegalStateException( 350 "This Builder should not be reused. Use a new Builder instance instead"); 351 } 352 } 353 } 354 355 @DataClass.Generated( 356 time = 1708721537301L, 357 codegenVersion = "1.0.23", 358 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Event.java", 359 inputSignatures = "private final long mEventId\nprivate final long mQueryId\nprivate final int mRowIndex\nprivate final @android.annotation.NonNull android.content.ComponentName mService\nprivate final int mType\nprivate final long mTimeMillis\nprivate final @android.annotation.Nullable byte[] mEventData\npublic java.lang.String getServiceName()\nclass Event extends java.lang.Object implements [java.io.Serializable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 360 @Deprecated __metadata()361 private void __metadata() {} 362 363 364 //@formatter:on 365 // End of generated code 366 367 } 368