1 /* 2 * Copyright (C) 2024 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.FlaggedApi; 20 import android.annotation.Nullable; 21 import android.os.Parcelable; 22 23 import com.android.adservices.ondevicepersonalization.flags.Flags; 24 import com.android.ondevicepersonalization.internal.util.DataClass; 25 26 /** 27 * One record of {@link TrainingExamplesOutput}. 28 */ 29 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED) 30 @DataClass(genBuilder = true, genAidl = false) 31 public final class TrainingExampleRecord implements Parcelable { 32 /** 33 * Training example byte arrays. The format is a binary serialized <a 34 * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto"> 35 * tensorflow.Example</a> proto. The maximum allowed example size is 50KB. 36 */ 37 @DataClass.MaySetToNull 38 @Nullable private byte[] mTrainingExample = null; 39 40 /** 41 * The resumption token byte arrays corresponding to training examples. The last processed 42 * example's corresponding resumption token will be passed to {@link 43 * IsolatedWorker#onTrainingExamples} to support resumption. 44 */ 45 @DataClass.MaySetToNull 46 @Nullable private byte[] mResumptionToken = null; 47 48 49 50 // Code below generated by codegen v1.0.23. 51 // 52 // DO NOT MODIFY! 53 // CHECKSTYLE:OFF Generated code 54 // 55 // To regenerate run: 56 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExampleRecord.java 57 // 58 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 59 // Settings > Editor > Code Style > Formatter Control 60 //@formatter:off 61 62 63 @DataClass.Generated.Member TrainingExampleRecord( @ullable byte[] trainingExample, @Nullable byte[] resumptionToken)64 /* package-private */ TrainingExampleRecord( 65 @Nullable byte[] trainingExample, 66 @Nullable byte[] resumptionToken) { 67 this.mTrainingExample = trainingExample; 68 this.mResumptionToken = resumptionToken; 69 70 // onConstructed(); // You can define this method to get a callback 71 } 72 73 /** 74 * Training example byte arrays. The format is a binary serialized <a 75 * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto"> 76 * tensorflow.Example</a> proto. The maximum allowed example size is 50KB. 77 */ 78 @DataClass.Generated.Member getTrainingExample()79 public @Nullable byte[] getTrainingExample() { 80 return mTrainingExample; 81 } 82 83 /** 84 * The resumption token byte arrays corresponding to training examples. The last processed 85 * example's corresponding resumption token will be passed to {@link 86 * IsolatedWorker#onTrainingExamples} to support resumption. 87 */ 88 @DataClass.Generated.Member getResumptionToken()89 public @Nullable byte[] getResumptionToken() { 90 return mResumptionToken; 91 } 92 93 @Override 94 @DataClass.Generated.Member writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)95 public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) { 96 // You can override field parcelling by defining methods like: 97 // void parcelFieldName(Parcel dest, int flags) { ... } 98 99 dest.writeByteArray(mTrainingExample); 100 dest.writeByteArray(mResumptionToken); 101 } 102 103 @Override 104 @DataClass.Generated.Member describeContents()105 public int describeContents() { return 0; } 106 107 /** @hide */ 108 @SuppressWarnings({"unchecked", "RedundantCast"}) 109 @DataClass.Generated.Member TrainingExampleRecord(@ndroid.annotation.NonNull android.os.Parcel in)110 /* package-private */ TrainingExampleRecord(@android.annotation.NonNull android.os.Parcel in) { 111 // You can override field unparcelling by defining methods like: 112 // static FieldType unparcelFieldName(Parcel in) { ... } 113 114 byte[] trainingExample = in.createByteArray(); 115 byte[] resumptionToken = in.createByteArray(); 116 117 this.mTrainingExample = trainingExample; 118 this.mResumptionToken = resumptionToken; 119 120 // onConstructed(); // You can define this method to get a callback 121 } 122 123 @DataClass.Generated.Member 124 public static final @android.annotation.NonNull Parcelable.Creator<TrainingExampleRecord> CREATOR 125 = new Parcelable.Creator<TrainingExampleRecord>() { 126 @Override 127 public TrainingExampleRecord[] newArray(int size) { 128 return new TrainingExampleRecord[size]; 129 } 130 131 @Override 132 public TrainingExampleRecord createFromParcel(@android.annotation.NonNull android.os.Parcel in) { 133 return new TrainingExampleRecord(in); 134 } 135 }; 136 137 /** 138 * A builder for {@link TrainingExampleRecord} 139 */ 140 @SuppressWarnings("WeakerAccess") 141 @DataClass.Generated.Member 142 public static final class Builder { 143 144 private @Nullable byte[] mTrainingExample; 145 private @Nullable byte[] mResumptionToken; 146 147 private long mBuilderFieldsSet = 0L; 148 Builder()149 public Builder() { 150 } 151 152 /** 153 * Training example byte arrays. The format is a binary serialized <a 154 * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto"> 155 * tensorflow.Example</a> proto. The maximum allowed example size is 50KB. 156 */ 157 @DataClass.Generated.Member setTrainingExample(@ullable byte... value)158 public @android.annotation.NonNull Builder setTrainingExample(@Nullable byte... value) { 159 checkNotUsed(); 160 mBuilderFieldsSet |= 0x1; 161 mTrainingExample = value; 162 return this; 163 } 164 165 /** 166 * The resumption token byte arrays corresponding to training examples. The last processed 167 * example's corresponding resumption token will be passed to {@link 168 * IsolatedWorker#onTrainingExamples} to support resumption. 169 */ 170 @DataClass.Generated.Member setResumptionToken(@ullable byte... value)171 public @android.annotation.NonNull Builder setResumptionToken(@Nullable byte... value) { 172 checkNotUsed(); 173 mBuilderFieldsSet |= 0x2; 174 mResumptionToken = value; 175 return this; 176 } 177 178 /** Builds the instance. This builder should not be touched after calling this! */ build()179 public @android.annotation.NonNull TrainingExampleRecord build() { 180 checkNotUsed(); 181 mBuilderFieldsSet |= 0x4; // Mark builder used 182 183 if ((mBuilderFieldsSet & 0x1) == 0) { 184 mTrainingExample = null; 185 } 186 if ((mBuilderFieldsSet & 0x2) == 0) { 187 mResumptionToken = null; 188 } 189 TrainingExampleRecord o = new TrainingExampleRecord( 190 mTrainingExample, 191 mResumptionToken); 192 return o; 193 } 194 checkNotUsed()195 private void checkNotUsed() { 196 if ((mBuilderFieldsSet & 0x4) != 0) { 197 throw new IllegalStateException( 198 "This Builder should not be reused. Use a new Builder instance instead"); 199 } 200 } 201 } 202 203 @DataClass.Generated( 204 time = 1707253849218L, 205 codegenVersion = "1.0.23", 206 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExampleRecord.java", 207 inputSignatures = "private @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable byte[] mTrainingExample\nprivate @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable byte[] mResumptionToken\nclass TrainingExampleRecord extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genAidl=false)") 208 @Deprecated __metadata()209 private void __metadata() {} 210 211 212 //@formatter:on 213 // End of generated code 214 215 } 216