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.os.Parcelable;
21 
22 import com.android.ondevicepersonalization.internal.util.DataClass;
23 
24 /**
25  * Wrapper class for additional information passed to IPC requests.
26 *
27 * @hide
28 */
29 @DataClass(genBuilder = true, genEqualsHashCode = true)
30 public final class CallerMetadata implements Parcelable {
31     /** Start time of the operation. */
32     private long mStartTimeMillis = 0;
33 
34 
35 
36     // Code below generated by codegen v1.0.23.
37     //
38     // DO NOT MODIFY!
39     // CHECKSTYLE:OFF Generated code
40     //
41     // To regenerate run:
42     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/CallerMetadata.java
43     //
44     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
45     //   Settings > Editor > Code Style > Formatter Control
46     //@formatter:off
47 
48 
49     @DataClass.Generated.Member
CallerMetadata( long startTimeMillis)50     /* package-private */ CallerMetadata(
51             long startTimeMillis) {
52         this.mStartTimeMillis = startTimeMillis;
53 
54         // onConstructed(); // You can define this method to get a callback
55     }
56 
57     /**
58      * Start time of the operation.
59      */
60     @DataClass.Generated.Member
getStartTimeMillis()61     public long getStartTimeMillis() {
62         return mStartTimeMillis;
63     }
64 
65     @Override
66     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)67     public boolean equals(@android.annotation.Nullable Object o) {
68         // You can override field equality logic by defining either of the methods like:
69         // boolean fieldNameEquals(CallerMetadata other) { ... }
70         // boolean fieldNameEquals(FieldType otherValue) { ... }
71 
72         if (this == o) return true;
73         if (o == null || getClass() != o.getClass()) return false;
74         @SuppressWarnings("unchecked")
75         CallerMetadata that = (CallerMetadata) o;
76         //noinspection PointlessBooleanExpression
77         return true
78                 && mStartTimeMillis == that.mStartTimeMillis;
79     }
80 
81     @Override
82     @DataClass.Generated.Member
hashCode()83     public int hashCode() {
84         // You can override field hashCode logic by defining methods like:
85         // int fieldNameHashCode() { ... }
86 
87         int _hash = 1;
88         _hash = 31 * _hash + Long.hashCode(mStartTimeMillis);
89         return _hash;
90     }
91 
92     @Override
93     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)94     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
95         // You can override field parcelling by defining methods like:
96         // void parcelFieldName(Parcel dest, int flags) { ... }
97 
98         dest.writeLong(mStartTimeMillis);
99     }
100 
101     @Override
102     @DataClass.Generated.Member
describeContents()103     public int describeContents() { return 0; }
104 
105     /** @hide */
106     @SuppressWarnings({"unchecked", "RedundantCast"})
107     @DataClass.Generated.Member
CallerMetadata(@onNull android.os.Parcel in)108     /* package-private */ CallerMetadata(@NonNull android.os.Parcel in) {
109         // You can override field unparcelling by defining methods like:
110         // static FieldType unparcelFieldName(Parcel in) { ... }
111 
112         long startTimeMillis = in.readLong();
113 
114         this.mStartTimeMillis = startTimeMillis;
115 
116         // onConstructed(); // You can define this method to get a callback
117     }
118 
119     @DataClass.Generated.Member
120     public static final @NonNull Parcelable.Creator<CallerMetadata> CREATOR
121             = new Parcelable.Creator<CallerMetadata>() {
122         @Override
123         public CallerMetadata[] newArray(int size) {
124             return new CallerMetadata[size];
125         }
126 
127         @Override
128         public CallerMetadata createFromParcel(@NonNull android.os.Parcel in) {
129             return new CallerMetadata(in);
130         }
131     };
132 
133     /**
134      * A builder for {@link CallerMetadata}
135      */
136     @SuppressWarnings("WeakerAccess")
137     @DataClass.Generated.Member
138     public static final class Builder {
139 
140         private long mStartTimeMillis;
141 
142         private long mBuilderFieldsSet = 0L;
143 
Builder()144         public Builder() {
145         }
146 
147         /**
148          * Start time of the operation.
149          */
150         @DataClass.Generated.Member
setStartTimeMillis(long value)151         public @NonNull Builder setStartTimeMillis(long value) {
152             checkNotUsed();
153             mBuilderFieldsSet |= 0x1;
154             mStartTimeMillis = value;
155             return this;
156         }
157 
158         /** Builds the instance. This builder should not be touched after calling this! */
build()159         public @NonNull CallerMetadata build() {
160             checkNotUsed();
161             mBuilderFieldsSet |= 0x2; // Mark builder used
162 
163             if ((mBuilderFieldsSet & 0x1) == 0) {
164                 mStartTimeMillis = 0;
165             }
166             CallerMetadata o = new CallerMetadata(
167                     mStartTimeMillis);
168             return o;
169         }
170 
checkNotUsed()171         private void checkNotUsed() {
172             if ((mBuilderFieldsSet & 0x2) != 0) {
173                 throw new IllegalStateException(
174                         "This Builder should not be reused. Use a new Builder instance instead");
175             }
176         }
177     }
178 
179     @DataClass.Generated(
180             time = 1696884555838L,
181             codegenVersion = "1.0.23",
182             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/CallerMetadata.java",
183             inputSignatures = "private  long mStartTimeMillis\nclass CallerMetadata extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
184     @Deprecated
__metadata()185     private void __metadata() {}
186 
187 
188     //@formatter:on
189     // End of generated code
190 
191 }
192