1 /*
2  * Copyright (C) 2018 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 package android.app.prediction;
17 
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /**
25  * The id for a prediction target. See {@link AppTarget}.
26  *
27  * @hide
28  */
29 @SystemApi
30 public final class AppTargetId implements Parcelable {
31 
32     @NonNull
33     private final String mId;
34 
35     /**
36      * Creates a new id for a prediction target.
37      *
38      * @hide
39      */
40     @SystemApi
AppTargetId(@onNull String id)41     public AppTargetId(@NonNull String id) {
42         mId = id;
43     }
44 
AppTargetId(Parcel parcel)45     private AppTargetId(Parcel parcel) {
46         mId = parcel.readString();
47     }
48 
49     /**
50      * Returns the id.
51      *
52      * @hide
53      */
54     @NonNull
getId()55     public String getId() {
56         return mId;
57     }
58 
59     @Override
equals(@ullable Object o)60     public boolean equals(@Nullable Object o) {
61         if (!getClass().equals(o != null ? o.getClass() : null)) return false;
62 
63         AppTargetId other = (AppTargetId) o;
64         return mId.equals(other.mId);
65     }
66 
67     @Override
hashCode()68     public int hashCode() {
69         return mId.hashCode();
70     }
71 
72     @Override
describeContents()73     public int describeContents() {
74         return 0;
75     }
76 
77     @Override
writeToParcel(Parcel dest, int flags)78     public void writeToParcel(Parcel dest, int flags) {
79         dest.writeString(mId);
80     }
81 
82     public static final @android.annotation.NonNull Creator<AppTargetId> CREATOR =
83             new Creator<AppTargetId>() {
84                 public AppTargetId createFromParcel(Parcel parcel) {
85                     return new AppTargetId(parcel);
86                 }
87 
88                 public AppTargetId[] newArray(int size) {
89                     return new AppTargetId[size];
90                 }
91             };
92 }
93