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 com.android.ondevicepersonalization.services.data.events; 18 19 import android.annotation.NonNull; 20 import android.content.ComponentName; 21 22 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 23 import com.android.ondevicepersonalization.internal.util.DataClass; 24 import com.android.ondevicepersonalization.services.data.DbUtils; 25 26 /** 27 * EventState object for the EventState table 28 */ 29 @DataClass( 30 genBuilder = true, 31 genEqualsHashCode = true 32 ) 33 public class EventState { 34 /** Token representing the event state. */ 35 @NonNull 36 private final byte[] mToken; 37 38 /** Name of the service package for this event */ 39 @NonNull 40 private final ComponentName mService; 41 42 /** Unique identifier of the task for processing this event */ 43 @NonNull 44 private final String mTaskIdentifier; 45 46 /** The name of the service */ getServiceName()47 public String getServiceName() { 48 return DbUtils.toTableValue(mService); 49 } 50 51 52 53 // Code below generated by codegen v1.0.23. 54 // 55 // DO NOT MODIFY! 56 // CHECKSTYLE:OFF Generated code 57 // 58 // To regenerate run: 59 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/EventState.java 60 // 61 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 62 // Settings > Editor > Code Style > Formatter Control 63 //@formatter:off 64 65 66 @DataClass.Generated.Member EventState( @onNull byte[] token, @NonNull ComponentName service, @NonNull String taskIdentifier)67 /* package-private */ EventState( 68 @NonNull byte[] token, 69 @NonNull ComponentName service, 70 @NonNull String taskIdentifier) { 71 this.mToken = token; 72 AnnotationValidations.validate( 73 NonNull.class, null, mToken); 74 this.mService = service; 75 AnnotationValidations.validate( 76 NonNull.class, null, mService); 77 this.mTaskIdentifier = taskIdentifier; 78 AnnotationValidations.validate( 79 NonNull.class, null, mTaskIdentifier); 80 81 // onConstructed(); // You can define this method to get a callback 82 } 83 84 /** 85 * Token representing the event state. 86 */ 87 @DataClass.Generated.Member getToken()88 public @NonNull byte[] getToken() { 89 return mToken; 90 } 91 92 /** 93 * Name of the service package for this event 94 */ 95 @DataClass.Generated.Member getService()96 public @NonNull ComponentName getService() { 97 return mService; 98 } 99 100 /** 101 * Unique identifier of the task for processing this event 102 */ 103 @DataClass.Generated.Member getTaskIdentifier()104 public @NonNull String getTaskIdentifier() { 105 return mTaskIdentifier; 106 } 107 108 @Override 109 @DataClass.Generated.Member equals(@ndroid.annotation.Nullable Object o)110 public boolean equals(@android.annotation.Nullable Object o) { 111 // You can override field equality logic by defining either of the methods like: 112 // boolean fieldNameEquals(EventState other) { ... } 113 // boolean fieldNameEquals(FieldType otherValue) { ... } 114 115 if (this == o) return true; 116 if (o == null || getClass() != o.getClass()) return false; 117 @SuppressWarnings("unchecked") 118 EventState that = (EventState) o; 119 //noinspection PointlessBooleanExpression 120 return true 121 && java.util.Arrays.equals(mToken, that.mToken) 122 && java.util.Objects.equals(mService, that.mService) 123 && java.util.Objects.equals(mTaskIdentifier, that.mTaskIdentifier); 124 } 125 126 @Override 127 @DataClass.Generated.Member hashCode()128 public int hashCode() { 129 // You can override field hashCode logic by defining methods like: 130 // int fieldNameHashCode() { ... } 131 132 int _hash = 1; 133 _hash = 31 * _hash + java.util.Arrays.hashCode(mToken); 134 _hash = 31 * _hash + java.util.Objects.hashCode(mService); 135 _hash = 31 * _hash + java.util.Objects.hashCode(mTaskIdentifier); 136 return _hash; 137 } 138 139 /** 140 * A builder for {@link EventState} 141 */ 142 @SuppressWarnings("WeakerAccess") 143 @DataClass.Generated.Member 144 public static class Builder { 145 146 private @NonNull byte[] mToken; 147 private @NonNull ComponentName mService; 148 private @NonNull String mTaskIdentifier; 149 150 private long mBuilderFieldsSet = 0L; 151 Builder()152 public Builder() { 153 } 154 155 /** 156 * Creates a new Builder. 157 * 158 * @param token 159 * Token representing the event state. 160 * @param service 161 * Name of the service package for this event 162 * @param taskIdentifier 163 * Unique identifier of the task for processing this event 164 */ Builder( @onNull byte[] token, @NonNull ComponentName service, @NonNull String taskIdentifier)165 public Builder( 166 @NonNull byte[] token, 167 @NonNull ComponentName service, 168 @NonNull String taskIdentifier) { 169 mToken = token; 170 AnnotationValidations.validate( 171 NonNull.class, null, mToken); 172 mService = service; 173 AnnotationValidations.validate( 174 NonNull.class, null, mService); 175 mTaskIdentifier = taskIdentifier; 176 AnnotationValidations.validate( 177 NonNull.class, null, mTaskIdentifier); 178 } 179 180 /** 181 * Token representing the event state. 182 */ 183 @DataClass.Generated.Member setToken(@onNull byte... value)184 public @NonNull Builder setToken(@NonNull byte... value) { 185 checkNotUsed(); 186 mBuilderFieldsSet |= 0x1; 187 mToken = value; 188 return this; 189 } 190 191 /** 192 * Name of the service package for this event 193 */ 194 @DataClass.Generated.Member setService(@onNull ComponentName value)195 public @NonNull Builder setService(@NonNull ComponentName value) { 196 checkNotUsed(); 197 mBuilderFieldsSet |= 0x2; 198 mService = value; 199 return this; 200 } 201 202 /** 203 * Unique identifier of the task for processing this event 204 */ 205 @DataClass.Generated.Member setTaskIdentifier(@onNull String value)206 public @NonNull Builder setTaskIdentifier(@NonNull String value) { 207 checkNotUsed(); 208 mBuilderFieldsSet |= 0x4; 209 mTaskIdentifier = value; 210 return this; 211 } 212 213 /** Builds the instance. This builder should not be touched after calling this! */ build()214 public @NonNull EventState build() { 215 checkNotUsed(); 216 mBuilderFieldsSet |= 0x8; // Mark builder used 217 218 EventState o = new EventState( 219 mToken, 220 mService, 221 mTaskIdentifier); 222 return o; 223 } 224 checkNotUsed()225 private void checkNotUsed() { 226 if ((mBuilderFieldsSet & 0x8) != 0) { 227 throw new IllegalStateException( 228 "This Builder should not be reused. Use a new Builder instance instead"); 229 } 230 } 231 } 232 233 @DataClass.Generated( 234 time = 1708721665919L, 235 codegenVersion = "1.0.23", 236 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/EventState.java", 237 inputSignatures = "private final @android.annotation.NonNull byte[] mToken\nprivate final @android.annotation.NonNull android.content.ComponentName mService\nprivate final @android.annotation.NonNull java.lang.String mTaskIdentifier\npublic java.lang.String getServiceName()\nclass EventState extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 238 @Deprecated __metadata()239 private void __metadata() {} 240 241 242 //@formatter:on 243 // End of generated code 244 245 } 246