| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.textclassifier; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Binder; |
| 22 |
import android.os.IBinder; |
| 23 |
import android.os.Parcel; |
| 24 |
import android.os.Parcelable; |
| 25 |
|
| 26 |
import java.util.Locale; |
| 27 |
import java.util.Objects; |
| 28 |
import java.util.UUID; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public final class TextClassificationSessionId implements Parcelable { |
| 34 |
@NonNull |
| 35 |
private final String mValue; |
| 36 |
@NonNull |
| 37 |
private final IBinder mToken; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public TextClassificationSessionId() { |
| 45 |
this(UUID.randomUUID().toString(), new Binder()); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public TextClassificationSessionId(@NonNull String value, @NonNull IBinder token) { |
| 56 |
mValue = Objects.requireNonNull(value); |
| 57 |
mToken = Objects.requireNonNull(token); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
@NonNull |
| 62 |
public IBinder getToken() { |
| 63 |
return mToken; |
| 64 |
} |
| 65 |
|
| 66 |
@Override |
| 67 |
public boolean equals(@Nullable Object o) { |
| 68 |
if (this == o) return true; |
| 69 |
if (o == null || getClass() != o.getClass()) return false; |
| 70 |
TextClassificationSessionId that = (TextClassificationSessionId) o; |
| 71 |
return Objects.equals(mValue, that.mValue) && Objects.equals(mToken, that.mToken); |
| 72 |
} |
| 73 |
|
| 74 |
@Override |
| 75 |
public int hashCode() { |
| 76 |
return Objects.hash(mValue, mToken); |
| 77 |
} |
| 78 |
|
| 79 |
@Override |
| 80 |
public String toString() { |
| 81 |
return String.format(Locale.US, "TextClassificationSessionId {%s}", mValue); |
| 82 |
} |
| 83 |
|
| 84 |
@Override |
| 85 |
public void writeToParcel(Parcel parcel, int flags) { |
| 86 |
parcel.writeString(mValue); |
| 87 |
parcel.writeStrongBinder(mToken); |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public int describeContents() { |
| 92 |
return 0; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
@NonNull |
| 99 |
public String getValue() { |
| 100 |
return mValue; |
| 101 |
} |
| 102 |
|
| 103 |
@NonNull |
| 104 |
public static final Parcelable.Creator<TextClassificationSessionId> CREATOR = |
| 105 |
new Parcelable.Creator<TextClassificationSessionId>() { |
| 106 |
@Override |
| 107 |
public TextClassificationSessionId createFromParcel(Parcel parcel) { |
| 108 |
return new TextClassificationSessionId( |
| 109 |
parcel.readString(), parcel.readStrongBinder()); |
| 110 |
} |
| 111 |
|
| 112 |
@Override |
| 113 |
public TextClassificationSessionId[] newArray(int size) { |
| 114 |
return new TextClassificationSessionId[size]; |
| 115 |
} |
| 116 |
}; |
| 117 |
} |