blob: 639ba78f76f5dfc1dfe724a11935620fa79e1c6c [file] [log] [blame]
Sunny Goyal54e91342018-11-14 11:59:02 -08001/*
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 */
16package android.app.prediction;
17
18import android.annotation.NonNull;
19import android.annotation.SystemApi;
Winson Chung5208cbe2019-01-11 20:51:46 -080020import android.annotation.TestApi;
Sunny Goyal54e91342018-11-14 11:59:02 -080021import android.os.Parcel;
22import android.os.Parcelable;
23
24/**
25 * The id for a prediction target.
26 * @hide
27 */
28@SystemApi
Winson Chung5208cbe2019-01-11 20:51:46 -080029@TestApi
Sunny Goyal54e91342018-11-14 11:59:02 -080030public final class AppTargetId implements Parcelable {
31
32 @NonNull
33 private final String mId;
34
35 /**
Winson Chung5208cbe2019-01-11 20:51:46 -080036 * TODO(b/123591863): Add java docs
37 *
Sunny Goyal54e91342018-11-14 11:59:02 -080038 * @hide
39 */
Winson Chung5208cbe2019-01-11 20:51:46 -080040 @SystemApi
41 @TestApi
Sunny Goyal54e91342018-11-14 11:59:02 -080042 public AppTargetId(@NonNull String id) {
43 mId = id;
44 }
45
46 private AppTargetId(Parcel parcel) {
47 mId = parcel.readString();
48 }
49
50 /**
51 * Returns the id.
52 * @hide
53 */
54 @NonNull
55 public String getId() {
56 return mId;
57 }
58
59 @Override
60 public boolean equals(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
68 public int hashCode() {
69 // Ensure that the id has a consistent hash
70 return mId.hashCode();
71 }
72
73 @Override
74 public int describeContents() {
75 return 0;
76 }
77
78 @Override
79 public void writeToParcel(Parcel dest, int flags) {
80 dest.writeString(mId);
81 }
82
83 /**
84 * @see Creator
85 */
86 public static final Creator<AppTargetId> CREATOR =
87 new Creator<AppTargetId>() {
88 public AppTargetId createFromParcel(Parcel parcel) {
89 return new AppTargetId(parcel);
90 }
91
92 public AppTargetId[] newArray(int size) {
93 return new AppTargetId[size];
94 }
95 };
96}