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