Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 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.SystemApi; |
Winson Chung | 5208cbe | 2019-01-11 20:51:46 -0800 | [diff] [blame] | 20 | import android.annotation.TestApi; |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | |
| 24 | /** |
| 25 | * TODO (b/111701043) : Add java doc |
| 26 | * |
| 27 | * @hide |
| 28 | */ |
| 29 | @SystemApi |
Winson Chung | 5208cbe | 2019-01-11 20:51:46 -0800 | [diff] [blame] | 30 | @TestApi |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 31 | public 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 | */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 78 | public static final @android.annotation.NonNull Parcelable.Creator<AppPredictionSessionId> CREATOR = |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 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 | } |