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.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Parcelable; 22 23 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 24 import com.android.ondevicepersonalization.internal.util.DataClass; 25 26 /** 27 * Parcelable version of {@link TrainingExamplesInput} 28 * 29 * @hide 30 */ 31 @DataClass(genAidl = false, genHiddenBuilder = true) 32 public final class TrainingExamplesInputParcel implements Parcelable { 33 /** The name of the federated compute population. */ 34 @NonNull private String mPopulationName = ""; 35 36 /** 37 * The name of the task within the population. One population may have multiple tasks. The task 38 * name can be used to uniquely identify the job. 39 */ 40 @NonNull private String mTaskName = ""; 41 42 /** Token used to support the resumption of training. */ 43 @Nullable private byte[] mResumptionToken = null; 44 45 /** The data collection name to use to create training examples. */ 46 @Nullable private String mCollectionName; 47 48 // Code below generated by codegen v1.0.23. 49 // 50 // DO NOT MODIFY! 51 // CHECKSTYLE:OFF Generated code 52 // 53 // To regenerate run: 54 // $ codegen 55 // $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExamplesInputParcel.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 @DataClass.Generated.Member TrainingExamplesInputParcel( @onNull String populationName, @NonNull String taskName, @Nullable byte[] resumptionToken, @Nullable String collectionName)62 /* package-private */ TrainingExamplesInputParcel( 63 @NonNull String populationName, 64 @NonNull String taskName, 65 @Nullable byte[] resumptionToken, 66 @Nullable String collectionName) { 67 this.mPopulationName = populationName; 68 AnnotationValidations.validate(NonNull.class, null, mPopulationName); 69 this.mTaskName = taskName; 70 AnnotationValidations.validate(NonNull.class, null, mTaskName); 71 this.mResumptionToken = resumptionToken; 72 this.mCollectionName = collectionName; 73 74 // onConstructed(); // You can define this method to get a callback 75 } 76 77 /** 78 * The name of the federated compute population. 79 */ 80 @DataClass.Generated.Member getPopulationName()81 public @NonNull String getPopulationName() { 82 return mPopulationName; 83 } 84 85 /** 86 * The name of the task within the population. One population may have multiple tasks. The task 87 * name can be used to uniquely identify the job. 88 */ 89 @DataClass.Generated.Member getTaskName()90 public @NonNull String getTaskName() { 91 return mTaskName; 92 } 93 94 /** 95 * Token used to support the resumption of training. 96 */ 97 @DataClass.Generated.Member getResumptionToken()98 public @Nullable byte[] getResumptionToken() { 99 return mResumptionToken; 100 } 101 102 /** The data collection name to use to create training examples. */ 103 @DataClass.Generated.Member getCollectionName()104 public @Nullable String getCollectionName() { 105 return mCollectionName; 106 } 107 108 @Override 109 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)110 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 111 // You can override field parcelling by defining methods like: 112 // void parcelFieldName(Parcel dest, int flags) { ... } 113 114 byte flg = 0; 115 if (mCollectionName != null) flg |= 0x8; 116 dest.writeByte(flg); 117 dest.writeString(mPopulationName); 118 dest.writeString(mTaskName); 119 dest.writeByteArray(mResumptionToken); 120 if (mCollectionName != null) dest.writeString(mCollectionName); 121 } 122 123 @Override 124 @DataClass.Generated.Member describeContents()125 public int describeContents() { return 0; } 126 127 /** @hide */ 128 @SuppressWarnings({"unchecked", "RedundantCast"}) 129 @DataClass.Generated.Member TrainingExamplesInputParcel(@onNull android.os.Parcel in)130 /* package-private */ TrainingExamplesInputParcel(@NonNull android.os.Parcel in) { 131 // You can override field unparcelling by defining methods like: 132 // static FieldType unparcelFieldName(Parcel in) { ... } 133 134 byte flg = in.readByte(); 135 String populationName = in.readString(); 136 String taskName = in.readString(); 137 byte[] resumptionToken = in.createByteArray(); 138 String collectionName = (flg & 0x8) == 0 ? null : in.readString(); 139 140 this.mPopulationName = populationName; 141 AnnotationValidations.validate(NonNull.class, null, mPopulationName); 142 this.mTaskName = taskName; 143 AnnotationValidations.validate( 144 NonNull.class, null, mTaskName); 145 this.mResumptionToken = resumptionToken; 146 this.mCollectionName = collectionName; 147 148 // onConstructed(); // You can define this method to get a callback 149 } 150 151 @DataClass.Generated.Member 152 public static final @NonNull Parcelable.Creator<TrainingExamplesInputParcel> CREATOR = 153 new Parcelable.Creator<TrainingExamplesInputParcel>() { 154 @Override 155 public TrainingExamplesInputParcel[] newArray(int size) { 156 return new TrainingExamplesInputParcel[size]; 157 } 158 159 @Override 160 public TrainingExamplesInputParcel createFromParcel(@NonNull android.os.Parcel in) { 161 return new TrainingExamplesInputParcel(in); 162 } 163 }; 164 165 /** 166 * A builder for {@link TrainingExamplesInputParcel} 167 * @hide 168 */ 169 @SuppressWarnings("WeakerAccess") 170 @DataClass.Generated.Member 171 public static final class Builder { 172 173 private @NonNull String mPopulationName; 174 private @NonNull String mTaskName; 175 private @Nullable byte[] mResumptionToken; 176 private @Nullable String mCollectionName; 177 178 private long mBuilderFieldsSet = 0L; 179 Builder()180 public Builder() {} 181 182 /** 183 * The name of the federated compute population. 184 */ 185 @DataClass.Generated.Member setPopulationName(@onNull String value)186 public @NonNull Builder setPopulationName(@NonNull String value) { 187 checkNotUsed(); 188 mBuilderFieldsSet |= 0x1; 189 mPopulationName = value; 190 return this; 191 } 192 193 /** 194 * The name of the task within the population. One population may have multiple tasks. The 195 * task name can be used to uniquely identify the job. 196 */ 197 @DataClass.Generated.Member setTaskName(@onNull String value)198 public @NonNull Builder setTaskName(@NonNull String value) { 199 checkNotUsed(); 200 mBuilderFieldsSet |= 0x2; 201 mTaskName = value; 202 return this; 203 } 204 205 /** 206 * Token used to support the resumption of training. 207 */ 208 @DataClass.Generated.Member setResumptionToken(@onNull byte... value)209 public @NonNull Builder setResumptionToken(@NonNull byte... value) { 210 checkNotUsed(); 211 mBuilderFieldsSet |= 0x4; 212 mResumptionToken = value; 213 return this; 214 } 215 216 /** The data collection name to use to create training examples. */ 217 @DataClass.Generated.Member setCollectionName(@onNull String value)218 public @NonNull Builder setCollectionName(@NonNull String value) { 219 checkNotUsed(); 220 mBuilderFieldsSet |= 0x8; 221 mCollectionName = value; 222 return this; 223 } 224 225 /** Builds the instance. This builder should not be touched after calling this! */ build()226 public @NonNull TrainingExamplesInputParcel build() { 227 checkNotUsed(); 228 mBuilderFieldsSet |= 0x10; // Mark builder used 229 230 if ((mBuilderFieldsSet & 0x1) == 0) { 231 mPopulationName = ""; 232 } 233 if ((mBuilderFieldsSet & 0x2) == 0) { 234 mTaskName = ""; 235 } 236 if ((mBuilderFieldsSet & 0x4) == 0) { 237 mResumptionToken = null; 238 } 239 TrainingExamplesInputParcel o = 240 new TrainingExamplesInputParcel( 241 mPopulationName, mTaskName, mResumptionToken, mCollectionName); 242 return o; 243 } 244 checkNotUsed()245 private void checkNotUsed() { 246 if ((mBuilderFieldsSet & 0x10) != 0) { 247 throw new IllegalStateException( 248 "This Builder should not be reused. Use a new Builder instance instead"); 249 } 250 } 251 } 252 253 @DataClass.Generated( 254 time = 1717526633865L, 255 codegenVersion = "1.0.23", 256 sourceFile = 257 "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExamplesInputParcel.java", 258 inputSignatures = 259 "private @android.annotation.NonNull java.lang.String mPopulationName\nprivate @android.annotation.NonNull java.lang.String mTaskName\nprivate @android.annotation.Nullable byte[] mResumptionToken\nprivate @android.annotation.Nullable java.lang.String mCollectionName\nclass TrainingExamplesInputParcel extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genAidl=false, genHiddenBuilder=true)") 260 @Deprecated __metadata()261 private void __metadata() {} 262 263 //@formatter:on 264 // End of generated code 265 266 } 267