Debian Codegraph @

core/java/android/view/contentcapture/ContentCaptureSessionId.java

raw symbols SCIP
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
17 package android.view.contentcapture;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 import java.io.PrintWriter;
25
26 /**
27 * Identifier for a Content Capture session.
28 */
29 public final class ContentCaptureSessionId implements Parcelable {
30
31 private final @NonNull int mValue;
32
33 /**
34 * Creates a new instance.
35 *
36 * @param value The internal value.
37 *
38 * @hide
39 */
40 public ContentCaptureSessionId(@NonNull int value) {
41 mValue = value;
42 }
43
44 /**
45 * @hide
46 */
47 public int getValue() {
48 return mValue;
49 }
50
51 @Override
52 public int hashCode() {
53 final int prime = 31;
54 int result = 1;
55 result = prime * result + mValue;
56 return result;
57 }
58
59 @Override
60 public boolean equals(@Nullable Object obj) {
61 if (this == obj) return true;
62 if (obj == null) return false;
63 if (getClass() != obj.getClass()) return false;
64 final ContentCaptureSessionId other = (ContentCaptureSessionId) obj;
65 if (mValue != other.mValue) return false;
66 return true;
67 }
68
69 /**
70 * {@inheritDoc}
71 *
72 * <p><b>NOTE: </b>this method is only useful for debugging purposes and is not guaranteed to
73 * be stable, hence it should not be used to identify the session.
74 */
75 @Override
76 public String toString() {
77 return Integer.toString(mValue);
78 }
79
80
81 /** @hide */
82 // TODO(b/111276913): dump to proto as well
83 public void dump(PrintWriter pw) {
84 pw.print(mValue);
85 }
86
87 @Override
88 public int describeContents() {
89 return 0;
90 }
91
92 @Override
93 public void writeToParcel(Parcel parcel, int flags) {
94 parcel.writeInt(mValue);
95 }
96
97 public static final @NonNull Parcelable.Creator<ContentCaptureSessionId> CREATOR =
98 new Parcelable.Creator<ContentCaptureSessionId>() {
99
100 @Override
101 @NonNull
102 public ContentCaptureSessionId createFromParcel(Parcel parcel) {
103 return new ContentCaptureSessionId(parcel.readInt());
104 }
105
106 @Override
107 @NonNull
108 public ContentCaptureSessionId[] newArray(int size) {
109 return new ContentCaptureSessionId[size];
110 }
111 };
112 }