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 /** 26 * Query object for the Query table 27 */ 28 @DataClass( 29 genBuilder = true, 30 genEqualsHashCode = true 31 ) 32 public class Query { 33 /** The id of the query. */ 34 private final long mQueryId; 35 36 /** Time of the query in milliseconds. */ 37 private final long mTimeMillis; 38 39 /** Name of the package that handled the request */ 40 @NonNull 41 private final String mServicePackageName; 42 43 /** Blob representing the query. */ 44 @NonNull 45 private final byte[] mQueryData; 46 47 48 49 // Code below generated by codegen v1.0.23. 50 // 51 // DO NOT MODIFY! 52 // CHECKSTYLE:OFF Generated code 53 // 54 // To regenerate run: 55 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Query.java 56 // 57 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 58 // Settings > Editor > Code Style > Formatter Control 59 //@formatter:off 60 61 62 @DataClass.Generated.Member Query( long queryId, long timeMillis, @NonNull String servicePackageName, @NonNull byte[] queryData)63 /* package-private */ Query( 64 long queryId, 65 long timeMillis, 66 @NonNull String servicePackageName, 67 @NonNull byte[] queryData) { 68 this.mQueryId = queryId; 69 this.mTimeMillis = timeMillis; 70 this.mServicePackageName = servicePackageName; 71 AnnotationValidations.validate( 72 NonNull.class, null, mServicePackageName); 73 this.mQueryData = queryData; 74 AnnotationValidations.validate( 75 NonNull.class, null, mQueryData); 76 77 // onConstructed(); // You can define this method to get a callback 78 } 79 80 /** 81 * The id of the query. 82 */ 83 @DataClass.Generated.Member getQueryId()84 public long getQueryId() { 85 return mQueryId; 86 } 87 88 /** 89 * Time of the query in milliseconds. 90 */ 91 @DataClass.Generated.Member getTimeMillis()92 public long getTimeMillis() { 93 return mTimeMillis; 94 } 95 96 /** 97 * Name of the package that handled the request 98 */ 99 @DataClass.Generated.Member getServicePackageName()100 public @NonNull String getServicePackageName() { 101 return mServicePackageName; 102 } 103 104 /** 105 * Blob representing the query. 106 */ 107 @DataClass.Generated.Member getQueryData()108 public @NonNull byte[] getQueryData() { 109 return mQueryData; 110 } 111 112 @Override 113 @DataClass.Generated.Member equals(@ullable Object o)114 public boolean equals(@Nullable Object o) { 115 // You can override field equality logic by defining either of the methods like: 116 // boolean fieldNameEquals(Query other) { ... } 117 // boolean fieldNameEquals(FieldType otherValue) { ... } 118 119 if (this == o) return true; 120 if (o == null || getClass() != o.getClass()) return false; 121 @SuppressWarnings("unchecked") 122 Query that = (Query) o; 123 //noinspection PointlessBooleanExpression 124 return true 125 && mQueryId == that.mQueryId 126 && mTimeMillis == that.mTimeMillis 127 && java.util.Objects.equals(mServicePackageName, that.mServicePackageName) 128 && java.util.Arrays.equals(mQueryData, that.mQueryData); 129 } 130 131 @Override 132 @DataClass.Generated.Member hashCode()133 public int hashCode() { 134 // You can override field hashCode logic by defining methods like: 135 // int fieldNameHashCode() { ... } 136 137 int _hash = 1; 138 _hash = 31 * _hash + Long.hashCode(mQueryId); 139 _hash = 31 * _hash + Long.hashCode(mTimeMillis); 140 _hash = 31 * _hash + java.util.Objects.hashCode(mServicePackageName); 141 _hash = 31 * _hash + java.util.Arrays.hashCode(mQueryData); 142 return _hash; 143 } 144 145 /** 146 * A builder for {@link Query} 147 */ 148 @SuppressWarnings("WeakerAccess") 149 @DataClass.Generated.Member 150 public static class Builder { 151 152 private long mQueryId; 153 private long mTimeMillis; 154 private @NonNull String mServicePackageName; 155 private @NonNull byte[] mQueryData; 156 157 private long mBuilderFieldsSet = 0L; 158 Builder()159 public Builder() { 160 } 161 162 /** 163 * Creates a new Builder. 164 * 165 * @param queryId 166 * The id of the query. 167 * @param timeMillis 168 * Time of the query in milliseconds. 169 * @param servicePackageName 170 * Name of the package that handled the request 171 * @param queryData 172 * Blob representing the query. 173 */ Builder( long queryId, long timeMillis, @NonNull String servicePackageName, @NonNull byte[] queryData)174 public Builder( 175 long queryId, 176 long timeMillis, 177 @NonNull String servicePackageName, 178 @NonNull byte[] queryData) { 179 mQueryId = queryId; 180 mTimeMillis = timeMillis; 181 mServicePackageName = servicePackageName; 182 AnnotationValidations.validate( 183 NonNull.class, null, mServicePackageName); 184 mQueryData = queryData; 185 AnnotationValidations.validate( 186 NonNull.class, null, mQueryData); 187 } 188 189 /** 190 * The id of the query. 191 */ 192 @DataClass.Generated.Member setQueryId(long value)193 public @NonNull Builder setQueryId(long value) { 194 checkNotUsed(); 195 mBuilderFieldsSet |= 0x1; 196 mQueryId = value; 197 return this; 198 } 199 200 /** 201 * Time of the query in milliseconds. 202 */ 203 @DataClass.Generated.Member setTimeMillis(long value)204 public @NonNull Builder setTimeMillis(long value) { 205 checkNotUsed(); 206 mBuilderFieldsSet |= 0x2; 207 mTimeMillis = value; 208 return this; 209 } 210 211 /** 212 * Name of the package that handled the request 213 */ 214 @DataClass.Generated.Member setServicePackageName(@onNull String value)215 public @NonNull Builder setServicePackageName(@NonNull String value) { 216 checkNotUsed(); 217 mBuilderFieldsSet |= 0x4; 218 mServicePackageName = value; 219 return this; 220 } 221 222 /** 223 * Blob representing the query. 224 */ 225 @DataClass.Generated.Member setQueryData(@onNull byte... value)226 public @NonNull Builder setQueryData(@NonNull byte... value) { 227 checkNotUsed(); 228 mBuilderFieldsSet |= 0x8; 229 mQueryData = value; 230 return this; 231 } 232 233 /** Builds the instance. This builder should not be touched after calling this! */ build()234 public @NonNull Query build() { 235 checkNotUsed(); 236 mBuilderFieldsSet |= 0x10; // Mark builder used 237 238 Query o = new Query( 239 mQueryId, 240 mTimeMillis, 241 mServicePackageName, 242 mQueryData); 243 return o; 244 } 245 checkNotUsed()246 private void checkNotUsed() { 247 if ((mBuilderFieldsSet & 0x10) != 0) { 248 throw new IllegalStateException( 249 "This Builder should not be reused. Use a new Builder instance instead"); 250 } 251 } 252 } 253 254 @DataClass.Generated( 255 time = 1680018439034L, 256 codegenVersion = "1.0.23", 257 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Query.java", 258 inputSignatures = "private final long mQueryId\nprivate final long mTimeMillis\nprivate final @android.annotation.NonNull java.lang.String mServicePackageName\nprivate final @android.annotation.NonNull byte[] mQueryData\nclass Query extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 259 @Deprecated __metadata()260 private void __metadata() {} 261 262 263 //@formatter:on 264 // End of generated code 265 266 } 267