blob: 1e76c241f8e908390fcf59bbef501c478e23ce0c [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 * TODO (b/111701043) : Add java doc
26 *
27 * @hide
28 */
29@SystemApi
Winson Chung5208cbe2019-01-11 20:51:46 -080030@TestApi
Sunny Goyal54e91342018-11-14 11:59:02 -080031public final class AppPredictionSessionId implements Parcelable {
32
33 private final String mId;
34
35 /**
36 * @hide
37 */
38 public AppPredictionSessionId(@NonNull String id) {
39 mId = id;
40 }
41
42 private AppPredictionSessionId(Parcel p) {
43 mId = p.readString();
44 }
45
46 @Override
47 public boolean equals(Object o) {
48 if (!getClass().equals(o != null ? o.getClass() : null)) return false;
49
50 AppPredictionSessionId other = (AppPredictionSessionId) o;
51 return mId.equals(other.mId);
52 }
53
54 @Override
55 public @NonNull String toString() {
56 return mId;
57 }
58
59 @Override
60 public int hashCode() {
61 // Ensure that the id has a consistent hash
62 return mId.hashCode();
63 }
64
65 @Override
66 public int describeContents() {
67 return 0;
68 }
69
70 @Override
71 public void writeToParcel(Parcel dest, int flags) {
72 dest.writeString(mId);
73 }
74
75 /**
76 * @see Parcelable.Creator
77 */
78 public static final Parcelable.Creator<AppPredictionSessionId> CREATOR =
79 new Parcelable.Creator<AppPredictionSessionId>() {
80 public AppPredictionSessionId createFromParcel(Parcel parcel) {
81 return new AppPredictionSessionId(parcel);
82 }
83
84 public AppPredictionSessionId[] newArray(int size) {
85 return new AppPredictionSessionId[size];
86 }
87 };
88}