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