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.FlaggedApi;
20 import android.annotation.NonNull;
21 
22 import com.android.adservices.ondevicepersonalization.flags.Flags;
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 import java.util.Collections;
28 import java.util.List;
29 
30 /** The output data of {@link IsolatedWorker#onTrainingExamples} */
31 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED)
32 @DataClass(genBuilder = true, genEqualsHashCode = true)
33 public final class TrainingExamplesOutput {
34     /**
35      * The list of training example byte arrays. The format is a binary serialized <a
36      * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto">
37      * tensorflow.Example</a> proto. The maximum allowed example size is 50KB.
38      */
39     @NonNull
40     @DataClass.PluralOf("trainingExampleRecord")
41     private List<TrainingExampleRecord> mTrainingExampleRecords = Collections.emptyList();
42 
43     // Code below generated by codegen v1.0.23.
44     //
45     // DO NOT MODIFY!
46     // CHECKSTYLE:OFF Generated code
47     //
48     // To regenerate run:
49     // $ codegen
50     // $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExamplesOutput.java
51     //
52     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
53     //   Settings > Editor > Code Style > Formatter Control
54     // @formatter:off
55 
56     @DataClass.Generated.Member
TrainingExamplesOutput( @onNull List<TrainingExampleRecord> trainingExampleRecords)57     /* package-private */ TrainingExamplesOutput(
58             @NonNull List<TrainingExampleRecord> trainingExampleRecords) {
59         this.mTrainingExampleRecords = trainingExampleRecords;
60         AnnotationValidations.validate(NonNull.class, null, mTrainingExampleRecords);
61 
62         // onConstructed(); // You can define this method to get a callback
63     }
64 
65     /**
66      * The list of training example byte arrays. The format is a binary serialized <a
67      * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto">
68      * tensorflow.Example</a> proto. The maximum allowed example size is 50KB.
69      */
70     @DataClass.Generated.Member
getTrainingExampleRecords()71     public @NonNull List<TrainingExampleRecord> getTrainingExampleRecords() {
72         return mTrainingExampleRecords;
73     }
74 
75     @Override
76     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)77     public boolean equals(@android.annotation.Nullable Object o) {
78         // You can override field equality logic by defining either of the methods like:
79         // boolean fieldNameEquals(TrainingExamplesOutput other) { ... }
80         // boolean fieldNameEquals(FieldType otherValue) { ... }
81 
82         if (this == o) return true;
83         if (o == null || getClass() != o.getClass()) return false;
84         @SuppressWarnings("unchecked")
85         TrainingExamplesOutput that = (TrainingExamplesOutput) o;
86         //noinspection PointlessBooleanExpression
87         return true
88                 && java.util.Objects.equals(mTrainingExampleRecords, that.mTrainingExampleRecords);
89     }
90 
91     @Override
92     @DataClass.Generated.Member
hashCode()93     public int hashCode() {
94         // You can override field hashCode logic by defining methods like:
95         // int fieldNameHashCode() { ... }
96 
97         int _hash = 1;
98         _hash = 31 * _hash + java.util.Objects.hashCode(mTrainingExampleRecords);
99         return _hash;
100     }
101 
102     /** A builder for {@link TrainingExamplesOutput} */
103     @SuppressWarnings("WeakerAccess")
104     @DataClass.Generated.Member
105     public static final class Builder {
106 
107         private @NonNull List<TrainingExampleRecord> mTrainingExampleRecords;
108 
109         private long mBuilderFieldsSet = 0L;
110 
Builder()111         public Builder() {}
112 
113         /**
114          * The list of training example byte arrays. The format is a binary serialized <a
115          * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto">
116          * tensorflow.Example</a> proto. The maximum allowed example size is 50KB.
117          */
118         @DataClass.Generated.Member
setTrainingExampleRecords( @onNull List<TrainingExampleRecord> value)119         public @NonNull Builder setTrainingExampleRecords(
120                 @NonNull List<TrainingExampleRecord> value) {
121             checkNotUsed();
122             mBuilderFieldsSet |= 0x1;
123             mTrainingExampleRecords = value;
124             return this;
125         }
126 
127         /**
128          * @see #setTrainingExampleRecords
129          */
130         @DataClass.Generated.Member
addTrainingExampleRecord(@onNull TrainingExampleRecord value)131         public @NonNull Builder addTrainingExampleRecord(@NonNull TrainingExampleRecord value) {
132             if (mTrainingExampleRecords == null)
133                 setTrainingExampleRecords(new java.util.ArrayList<>());
134             mTrainingExampleRecords.add(value);
135             return this;
136         }
137 
138         /** Builds the instance. This builder should not be touched after calling this! */
build()139         public @NonNull TrainingExamplesOutput build() {
140             checkNotUsed();
141             mBuilderFieldsSet |= 0x2; // Mark builder used
142 
143             if ((mBuilderFieldsSet & 0x1) == 0) {
144                 mTrainingExampleRecords = Collections.emptyList();
145             }
146             TrainingExamplesOutput o = new TrainingExamplesOutput(mTrainingExampleRecords);
147             return o;
148         }
149 
checkNotUsed()150         private void checkNotUsed() {
151             if ((mBuilderFieldsSet & 0x2) != 0) {
152                 throw new IllegalStateException(
153                         "This Builder should not be reused. Use a new Builder instance instead");
154             }
155         }
156     }
157 
158     @DataClass.Generated(
159             time = 1704915709729L,
160             codegenVersion = "1.0.23",
161             sourceFile =
162                     "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/TrainingExamplesOutput.java",
163             inputSignatures =
164                     "private @android.annotation.NonNull"
165                         + " @com.android.ondevicepersonalization.internal.util.DataClass.PluralOf(\"trainingExampleRecord\")"
166                         + " java.util.List<android.adservices.ondevicepersonalization.TrainingExampleRecord>"
167                         + " mTrainingExampleRecords\n"
168                         + "class TrainingExamplesOutput extends java.lang.Object implements []\n"
169                         + "@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true,"
170                         + " genEqualsHashCode=true)")
171     @Deprecated
__metadata()172     private void __metadata() {}
173 
174     // @formatter:on
175     // End of generated code
176 
177 }
178