1 /* 2 * Copyright (C) 2023 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.ondevicepersonalization; 18 19 import android.annotation.Nullable; 20 import android.os.Parcelable; 21 22 import com.android.ondevicepersonalization.internal.util.DataClass; 23 24 /** 25 * The inputs required for computing event-level metrics to be logged. 26 * 27 * @hide 28 */ 29 @DataClass(genBuilder = true, genEqualsHashCode = true) 30 public final class EventInput implements Parcelable { 31 /** The type of the event. */ 32 private int mEventType = 0; 33 34 /** The {@link Bid} that this event is for. */ 35 @Nullable private Bid mBid = null; 36 37 38 39 // Code below generated by codegen v1.0.23. 40 // 41 // DO NOT MODIFY! 42 // CHECKSTYLE:OFF Generated code 43 // 44 // To regenerate run: 45 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventInput.java 46 // 47 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 48 // Settings > Editor > Code Style > Formatter Control 49 //@formatter:off 50 51 52 @DataClass.Generated.Member EventInput( int eventType, @Nullable Bid bid)53 /* package-private */ EventInput( 54 int eventType, 55 @Nullable Bid bid) { 56 this.mEventType = eventType; 57 this.mBid = bid; 58 59 // onConstructed(); // You can define this method to get a callback 60 } 61 62 /** 63 * The type of the event. 64 */ 65 @DataClass.Generated.Member getEventType()66 public int getEventType() { 67 return mEventType; 68 } 69 70 /** 71 * The {@link Bid} that this event is for. 72 */ 73 @DataClass.Generated.Member getBid()74 public @Nullable Bid getBid() { 75 return mBid; 76 } 77 78 @Override 79 @DataClass.Generated.Member equals(@ullable Object o)80 public boolean equals(@Nullable Object o) { 81 // You can override field equality logic by defining either of the methods like: 82 // boolean fieldNameEquals(EventInput other) { ... } 83 // boolean fieldNameEquals(FieldType otherValue) { ... } 84 85 if (this == o) return true; 86 if (o == null || getClass() != o.getClass()) return false; 87 @SuppressWarnings("unchecked") 88 EventInput that = (EventInput) o; 89 //noinspection PointlessBooleanExpression 90 return true 91 && mEventType == that.mEventType 92 && java.util.Objects.equals(mBid, that.mBid); 93 } 94 95 @Override 96 @DataClass.Generated.Member hashCode()97 public int hashCode() { 98 // You can override field hashCode logic by defining methods like: 99 // int fieldNameHashCode() { ... } 100 101 int _hash = 1; 102 _hash = 31 * _hash + mEventType; 103 _hash = 31 * _hash + java.util.Objects.hashCode(mBid); 104 return _hash; 105 } 106 107 @Override 108 @DataClass.Generated.Member writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)109 public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) { 110 // You can override field parcelling by defining methods like: 111 // void parcelFieldName(Parcel dest, int flags) { ... } 112 113 byte flg = 0; 114 if (mBid != null) flg |= 0x2; 115 dest.writeByte(flg); 116 dest.writeInt(mEventType); 117 if (mBid != null) dest.writeTypedObject(mBid, flags); 118 } 119 120 @Override 121 @DataClass.Generated.Member describeContents()122 public int describeContents() { return 0; } 123 124 /** @hide */ 125 @SuppressWarnings({"unchecked", "RedundantCast"}) 126 @DataClass.Generated.Member EventInput(@ndroid.annotation.NonNull android.os.Parcel in)127 /* package-private */ EventInput(@android.annotation.NonNull android.os.Parcel in) { 128 // You can override field unparcelling by defining methods like: 129 // static FieldType unparcelFieldName(Parcel in) { ... } 130 131 byte flg = in.readByte(); 132 int eventType = in.readInt(); 133 Bid bid = (flg & 0x2) == 0 ? null : (Bid) in.readTypedObject(Bid.CREATOR); 134 135 this.mEventType = eventType; 136 this.mBid = bid; 137 138 // onConstructed(); // You can define this method to get a callback 139 } 140 141 @DataClass.Generated.Member 142 public static final @android.annotation.NonNull Parcelable.Creator<EventInput> CREATOR 143 = new Parcelable.Creator<EventInput>() { 144 @Override 145 public EventInput[] newArray(int size) { 146 return new EventInput[size]; 147 } 148 149 @Override 150 public EventInput createFromParcel(@android.annotation.NonNull android.os.Parcel in) { 151 return new EventInput(in); 152 } 153 }; 154 155 /** 156 * A builder for {@link EventInput} 157 */ 158 @SuppressWarnings("WeakerAccess") 159 @DataClass.Generated.Member 160 public static final class Builder { 161 162 private int mEventType; 163 private @Nullable Bid mBid; 164 165 private long mBuilderFieldsSet = 0L; 166 Builder()167 public Builder() { 168 } 169 170 /** 171 * The type of the event. 172 */ 173 @DataClass.Generated.Member setEventType(int value)174 public @android.annotation.NonNull Builder setEventType(int value) { 175 checkNotUsed(); 176 mBuilderFieldsSet |= 0x1; 177 mEventType = value; 178 return this; 179 } 180 181 /** 182 * The {@link Bid} that this event is for. 183 */ 184 @DataClass.Generated.Member setBid(@ndroid.annotation.NonNull Bid value)185 public @android.annotation.NonNull Builder setBid(@android.annotation.NonNull Bid value) { 186 checkNotUsed(); 187 mBuilderFieldsSet |= 0x2; 188 mBid = value; 189 return this; 190 } 191 192 /** Builds the instance. This builder should not be touched after calling this! */ build()193 public @android.annotation.NonNull EventInput build() { 194 checkNotUsed(); 195 mBuilderFieldsSet |= 0x4; // Mark builder used 196 197 if ((mBuilderFieldsSet & 0x1) == 0) { 198 mEventType = 0; 199 } 200 if ((mBuilderFieldsSet & 0x2) == 0) { 201 mBid = null; 202 } 203 EventInput o = new EventInput( 204 mEventType, 205 mBid); 206 return o; 207 } 208 checkNotUsed()209 private void checkNotUsed() { 210 if ((mBuilderFieldsSet & 0x4) != 0) { 211 throw new IllegalStateException( 212 "This Builder should not be reused. Use a new Builder instance instead"); 213 } 214 } 215 } 216 217 @DataClass.Generated( 218 time = 1681339263640L, 219 codegenVersion = "1.0.23", 220 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventInput.java", 221 inputSignatures = "private int mEventType\nprivate @android.annotation.Nullable android.ondevicepersonalization.Bid mBid\nclass EventInput extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 222 @Deprecated __metadata()223 private void __metadata() {} 224 225 226 //@formatter:on 227 // End of generated code 228 229 } 230