1 /* 2 * Copyright (C) 2023 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.federatedcompute.common; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Parcelable; 22 23 import com.android.internal.util.Preconditions; 24 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 25 import com.android.ondevicepersonalization.internal.util.DataClass; 26 27 /** 28 * A container for information regarding an example store access, including the task name, the 29 * selection criteria and the number of examples which has been used. 30 * 31 * @hide 32 */ 33 @DataClass(genBuilder = true, genEqualsHashCode = true) 34 public class ExampleConsumption implements Parcelable { 35 @NonNull private String mTaskId; 36 37 @Nullable private byte[] mSelectionCriteria; 38 39 private int mExampleCount; 40 41 @Nullable private byte[] mResumptionToken; 42 43 @Nullable private String mCollectionUri; 44 45 // Code below generated by codegen v1.0.23. 46 // 47 // DO NOT MODIFY! 48 // CHECKSTYLE:OFF Generated code 49 // 50 // To regenerate run: 51 // $ codegen 52 // $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/federatedcompute/common/ExampleConsumption.java 53 // 54 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 55 // Settings > Editor > Code Style > Formatter Control 56 // @formatter:off 57 58 @DataClass.Generated.Member ExampleConsumption( @onNull String taskId, @Nullable byte[] selectionCriteria, int exampleCount, @Nullable byte[] resumptionToken, @Nullable String collectionUri)59 /* package-private */ ExampleConsumption( 60 @NonNull String taskId, 61 @Nullable byte[] selectionCriteria, 62 int exampleCount, 63 @Nullable byte[] resumptionToken, 64 @Nullable String collectionUri) { 65 this.mTaskId = taskId; 66 AnnotationValidations.validate(NonNull.class, null, mTaskId); 67 this.mSelectionCriteria = selectionCriteria; 68 this.mExampleCount = exampleCount; 69 this.mResumptionToken = resumptionToken; 70 this.mCollectionUri = collectionUri; 71 72 // onConstructed(); // You can define this method to get a callback 73 } 74 75 @DataClass.Generated.Member getTaskId()76 public @NonNull String getTaskId() { 77 return mTaskId; 78 } 79 80 @DataClass.Generated.Member getSelectionCriteria()81 public @Nullable byte[] getSelectionCriteria() { 82 return mSelectionCriteria; 83 } 84 85 @DataClass.Generated.Member getExampleCount()86 public int getExampleCount() { 87 return mExampleCount; 88 } 89 90 @DataClass.Generated.Member getResumptionToken()91 public @Nullable byte[] getResumptionToken() { 92 return mResumptionToken; 93 } 94 95 @DataClass.Generated.Member getCollectionUri()96 public @Nullable String getCollectionUri() { 97 return mCollectionUri; 98 } 99 100 @Override 101 @DataClass.Generated.Member equals(@ullable Object o)102 public boolean equals(@Nullable Object o) { 103 // You can override field equality logic by defining either of the methods like: 104 // boolean fieldNameEquals(ExampleConsumption other) { ... } 105 // boolean fieldNameEquals(FieldType otherValue) { ... } 106 107 if (this == o) return true; 108 if (o == null || getClass() != o.getClass()) return false; 109 @SuppressWarnings("unchecked") 110 ExampleConsumption that = (ExampleConsumption) o; 111 //noinspection PointlessBooleanExpression 112 return true 113 && java.util.Objects.equals(mTaskId, that.mTaskId) 114 && java.util.Arrays.equals(mSelectionCriteria, that.mSelectionCriteria) 115 && mExampleCount == that.mExampleCount 116 && java.util.Arrays.equals(mResumptionToken, that.mResumptionToken) 117 && java.util.Objects.equals(mCollectionUri, that.mCollectionUri); 118 } 119 120 @Override 121 @DataClass.Generated.Member hashCode()122 public int hashCode() { 123 // You can override field hashCode logic by defining methods like: 124 // int fieldNameHashCode() { ... } 125 126 int _hash = 1; 127 _hash = 31 * _hash + java.util.Objects.hashCode(mTaskId); 128 _hash = 31 * _hash + java.util.Arrays.hashCode(mSelectionCriteria); 129 _hash = 31 * _hash + mExampleCount; 130 _hash = 31 * _hash + java.util.Arrays.hashCode(mResumptionToken); 131 _hash = 31 * _hash + java.util.Objects.hashCode(mCollectionUri); 132 return _hash; 133 } 134 135 @Override 136 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)137 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 138 // You can override field parcelling by defining methods like: 139 // void parcelFieldName(Parcel dest, int flags) { ... } 140 141 byte flg = 0; 142 if (mCollectionUri != null) flg |= 0x10; 143 dest.writeByte(flg); 144 dest.writeString(mTaskId); 145 dest.writeByteArray(mSelectionCriteria); 146 dest.writeInt(mExampleCount); 147 dest.writeByteArray(mResumptionToken); 148 if (mCollectionUri != null) dest.writeString(mCollectionUri); 149 } 150 151 @Override 152 @DataClass.Generated.Member describeContents()153 public int describeContents() { 154 return 0; 155 } 156 157 /** @hide */ 158 @SuppressWarnings({"unchecked", "RedundantCast"}) 159 @DataClass.Generated.Member ExampleConsumption(@onNull android.os.Parcel in)160 protected ExampleConsumption(@NonNull android.os.Parcel in) { 161 // You can override field unparcelling by defining methods like: 162 // static FieldType unparcelFieldName(Parcel in) { ... } 163 164 byte flg = in.readByte(); 165 String taskId = in.readString(); 166 byte[] selectionCriteria = in.createByteArray(); 167 int exampleCount = in.readInt(); 168 byte[] resumptionToken = in.createByteArray(); 169 String collectionUri = (flg & 0x10) == 0 ? null : in.readString(); 170 171 this.mTaskId = taskId; 172 AnnotationValidations.validate(NonNull.class, null, mTaskId); 173 this.mSelectionCriteria = selectionCriteria; 174 this.mExampleCount = exampleCount; 175 this.mResumptionToken = resumptionToken; 176 this.mCollectionUri = collectionUri; 177 178 // onConstructed(); // You can define this method to get a callback 179 } 180 181 @DataClass.Generated.Member 182 public static final @NonNull Parcelable.Creator<ExampleConsumption> CREATOR = 183 new Parcelable.Creator<ExampleConsumption>() { 184 @Override 185 public ExampleConsumption[] newArray(int size) { 186 return new ExampleConsumption[size]; 187 } 188 189 @Override 190 public ExampleConsumption createFromParcel(@NonNull android.os.Parcel in) { 191 return new ExampleConsumption(in); 192 } 193 }; 194 195 /** A builder for {@link ExampleConsumption} */ 196 @SuppressWarnings("WeakerAccess") 197 @DataClass.Generated.Member 198 public static class Builder { 199 200 private @NonNull String mTaskId; 201 private @Nullable byte[] mSelectionCriteria; 202 private int mExampleCount; 203 private @Nullable byte[] mResumptionToken; 204 private @Nullable String mCollectionUri; 205 206 private long mBuilderFieldsSet = 0L; 207 Builder()208 public Builder() {} 209 210 @DataClass.Generated.Member setTaskId(@onNull String value)211 public @NonNull Builder setTaskId(@NonNull String value) { 212 checkNotUsed(); 213 Preconditions.checkStringNotEmpty(value); 214 mBuilderFieldsSet |= 0x1; 215 mTaskId = value; 216 return this; 217 } 218 219 @DataClass.Generated.Member setSelectionCriteria(@onNull byte... value)220 public @NonNull Builder setSelectionCriteria(@NonNull byte... value) { 221 checkNotUsed(); 222 mBuilderFieldsSet |= 0x2; 223 mSelectionCriteria = value; 224 return this; 225 } 226 227 @DataClass.Generated.Member setExampleCount(int value)228 public @NonNull Builder setExampleCount(int value) { 229 checkNotUsed(); 230 mBuilderFieldsSet |= 0x4; 231 mExampleCount = value; 232 return this; 233 } 234 235 @DataClass.Generated.Member setResumptionToken(@onNull byte... value)236 public @NonNull Builder setResumptionToken(@NonNull byte... value) { 237 checkNotUsed(); 238 mBuilderFieldsSet |= 0x8; 239 mResumptionToken = value; 240 return this; 241 } 242 243 @DataClass.Generated.Member setCollectionUri(@onNull String value)244 public @NonNull Builder setCollectionUri(@NonNull String value) { 245 checkNotUsed(); 246 mBuilderFieldsSet |= 0x10; 247 mCollectionUri = value; 248 return this; 249 } 250 251 /** Builds the instance. This builder should not be touched after calling this! */ build()252 public @NonNull ExampleConsumption build() { 253 checkNotUsed(); 254 mBuilderFieldsSet |= 0x20; // Mark builder used 255 256 ExampleConsumption o = 257 new ExampleConsumption( 258 mTaskId, 259 mSelectionCriteria, 260 mExampleCount, 261 mResumptionToken, 262 mCollectionUri); 263 return o; 264 } 265 checkNotUsed()266 private void checkNotUsed() { 267 if ((mBuilderFieldsSet & 0x20) != 0) { 268 throw new IllegalStateException( 269 "This Builder should not be reused. Use a new Builder instance instead"); 270 } 271 } 272 } 273 274 @DataClass.Generated( 275 time = 1714846062890L, 276 codegenVersion = "1.0.23", 277 sourceFile = 278 "packages/modules/OnDevicePersonalization/framework/java/android/federatedcompute/common/ExampleConsumption.java", 279 inputSignatures = 280 "private @android.annotation.NonNull java.lang.String mTaskId\nprivate @android.annotation.Nullable byte[] mSelectionCriteria\nprivate int mExampleCount\nprivate @android.annotation.Nullable byte[] mResumptionToken\nprivate @android.annotation.Nullable java.lang.String mCollectionUri\nclass ExampleConsumption extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 281 @Deprecated __metadata()282 private void __metadata() {} 283 284 // @formatter:on 285 // End of generated code 286 287 } 288