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 * A list of metrics to be logged in the Query or Events table. 26 * 27 * @hide 28 */ 29 @DataClass(genBuilder = true, genEqualsHashCode = true) 30 public final class Metrics implements Parcelable { 31 /** Integer or fixed point metric values. */ 32 @Nullable private long[] mLongValues = null; 33 34 /** Floating point metric values. */ 35 @Nullable private double[] mDoubleValues = null; 36 37 /** Boolean metric values. */ 38 @Nullable private boolean[] mBooleanValues = null; 39 40 41 42 // Code below generated by codegen v1.0.23. 43 // 44 // DO NOT MODIFY! 45 // CHECKSTYLE:OFF Generated code 46 // 47 // To regenerate run: 48 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/Metrics.java 49 // 50 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 51 // Settings > Editor > Code Style > Formatter Control 52 //@formatter:off 53 54 55 @DataClass.Generated.Member Metrics( @ullable long[] longValues, @Nullable double[] doubleValues, @Nullable boolean[] booleanValues)56 /* package-private */ Metrics( 57 @Nullable long[] longValues, 58 @Nullable double[] doubleValues, 59 @Nullable boolean[] booleanValues) { 60 this.mLongValues = longValues; 61 this.mDoubleValues = doubleValues; 62 this.mBooleanValues = booleanValues; 63 64 // onConstructed(); // You can define this method to get a callback 65 } 66 67 /** 68 * Integer or fixed point metric values. 69 */ 70 @DataClass.Generated.Member getLongValues()71 public @Nullable long[] getLongValues() { 72 return mLongValues; 73 } 74 75 /** 76 * Floating point metric values. 77 */ 78 @DataClass.Generated.Member getDoubleValues()79 public @Nullable double[] getDoubleValues() { 80 return mDoubleValues; 81 } 82 83 /** 84 * Boolean metric values. 85 */ 86 @DataClass.Generated.Member getBooleanValues()87 public @Nullable boolean[] getBooleanValues() { 88 return mBooleanValues; 89 } 90 91 @Override 92 @DataClass.Generated.Member equals(@ullable Object o)93 public boolean equals(@Nullable Object o) { 94 // You can override field equality logic by defining either of the methods like: 95 // boolean fieldNameEquals(Metrics other) { ... } 96 // boolean fieldNameEquals(FieldType otherValue) { ... } 97 98 if (this == o) return true; 99 if (o == null || getClass() != o.getClass()) return false; 100 @SuppressWarnings("unchecked") 101 Metrics that = (Metrics) o; 102 //noinspection PointlessBooleanExpression 103 return true 104 && java.util.Arrays.equals(mLongValues, that.mLongValues) 105 && java.util.Arrays.equals(mDoubleValues, that.mDoubleValues) 106 && java.util.Arrays.equals(mBooleanValues, that.mBooleanValues); 107 } 108 109 @Override 110 @DataClass.Generated.Member hashCode()111 public int hashCode() { 112 // You can override field hashCode logic by defining methods like: 113 // int fieldNameHashCode() { ... } 114 115 int _hash = 1; 116 _hash = 31 * _hash + java.util.Arrays.hashCode(mLongValues); 117 _hash = 31 * _hash + java.util.Arrays.hashCode(mDoubleValues); 118 _hash = 31 * _hash + java.util.Arrays.hashCode(mBooleanValues); 119 return _hash; 120 } 121 122 @Override 123 @DataClass.Generated.Member writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)124 public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) { 125 // You can override field parcelling by defining methods like: 126 // void parcelFieldName(Parcel dest, int flags) { ... } 127 128 byte flg = 0; 129 if (mLongValues != null) flg |= 0x1; 130 if (mDoubleValues != null) flg |= 0x2; 131 if (mBooleanValues != null) flg |= 0x4; 132 dest.writeByte(flg); 133 if (mLongValues != null) dest.writeLongArray(mLongValues); 134 if (mDoubleValues != null) dest.writeDoubleArray(mDoubleValues); 135 if (mBooleanValues != null) dest.writeBooleanArray(mBooleanValues); 136 } 137 138 @Override 139 @DataClass.Generated.Member describeContents()140 public int describeContents() { return 0; } 141 142 /** @hide */ 143 @SuppressWarnings({"unchecked", "RedundantCast"}) 144 @DataClass.Generated.Member Metrics(@ndroid.annotation.NonNull android.os.Parcel in)145 /* package-private */ Metrics(@android.annotation.NonNull android.os.Parcel in) { 146 // You can override field unparcelling by defining methods like: 147 // static FieldType unparcelFieldName(Parcel in) { ... } 148 149 byte flg = in.readByte(); 150 long[] longValues = (flg & 0x1) == 0 ? null : in.createLongArray(); 151 double[] doubleValues = (flg & 0x2) == 0 ? null : in.createDoubleArray(); 152 boolean[] booleanValues = (flg & 0x4) == 0 ? null : in.createBooleanArray(); 153 154 this.mLongValues = longValues; 155 this.mDoubleValues = doubleValues; 156 this.mBooleanValues = booleanValues; 157 158 // onConstructed(); // You can define this method to get a callback 159 } 160 161 @DataClass.Generated.Member 162 public static final @android.annotation.NonNull Parcelable.Creator<Metrics> CREATOR 163 = new Parcelable.Creator<Metrics>() { 164 @Override 165 public Metrics[] newArray(int size) { 166 return new Metrics[size]; 167 } 168 169 @Override 170 public Metrics createFromParcel(@android.annotation.NonNull android.os.Parcel in) { 171 return new Metrics(in); 172 } 173 }; 174 175 /** 176 * A builder for {@link Metrics} 177 */ 178 @SuppressWarnings("WeakerAccess") 179 @DataClass.Generated.Member 180 public static final class Builder { 181 182 private @Nullable long[] mLongValues; 183 private @Nullable double[] mDoubleValues; 184 private @Nullable boolean[] mBooleanValues; 185 186 private long mBuilderFieldsSet = 0L; 187 Builder()188 public Builder() { 189 } 190 191 /** 192 * Integer or fixed point metric values. 193 */ 194 @DataClass.Generated.Member setLongValues(@ndroid.annotation.NonNull long... value)195 public @android.annotation.NonNull Builder setLongValues(@android.annotation.NonNull long... value) { 196 checkNotUsed(); 197 mBuilderFieldsSet |= 0x1; 198 mLongValues = value; 199 return this; 200 } 201 202 /** 203 * Floating point metric values. 204 */ 205 @DataClass.Generated.Member setDoubleValues(@ndroid.annotation.NonNull double... value)206 public @android.annotation.NonNull Builder setDoubleValues(@android.annotation.NonNull double... value) { 207 checkNotUsed(); 208 mBuilderFieldsSet |= 0x2; 209 mDoubleValues = value; 210 return this; 211 } 212 213 /** 214 * Boolean metric values. 215 */ 216 @DataClass.Generated.Member setBooleanValues(@ndroid.annotation.NonNull boolean... value)217 public @android.annotation.NonNull Builder setBooleanValues(@android.annotation.NonNull boolean... value) { 218 checkNotUsed(); 219 mBuilderFieldsSet |= 0x4; 220 mBooleanValues = value; 221 return this; 222 } 223 224 /** Builds the instance. This builder should not be touched after calling this! */ build()225 public @android.annotation.NonNull Metrics build() { 226 checkNotUsed(); 227 mBuilderFieldsSet |= 0x8; // Mark builder used 228 229 if ((mBuilderFieldsSet & 0x1) == 0) { 230 mLongValues = null; 231 } 232 if ((mBuilderFieldsSet & 0x2) == 0) { 233 mDoubleValues = null; 234 } 235 if ((mBuilderFieldsSet & 0x4) == 0) { 236 mBooleanValues = null; 237 } 238 Metrics o = new Metrics( 239 mLongValues, 240 mDoubleValues, 241 mBooleanValues); 242 return o; 243 } 244 checkNotUsed()245 private void checkNotUsed() { 246 if ((mBuilderFieldsSet & 0x8) != 0) { 247 throw new IllegalStateException( 248 "This Builder should not be reused. Use a new Builder instance instead"); 249 } 250 } 251 } 252 253 @DataClass.Generated( 254 time = 1681840610478L, 255 codegenVersion = "1.0.23", 256 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/Metrics.java", 257 inputSignatures = "private @android.annotation.Nullable long[] mLongValues\nprivate @android.annotation.Nullable double[] mDoubleValues\nprivate @android.annotation.Nullable boolean[] mBooleanValues\nclass Metrics extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 258 @Deprecated __metadata()259 private void __metadata() {} 260 261 262 //@formatter:on 263 // End of generated code 264 265 } 266