| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.print; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import com.android.internal.util.Preconditions; |
| 25 |
|
| 26 |
import java.util.UUID; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final class PrintJobId implements Parcelable { |
| 32 |
private final @NonNull String mValue; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public PrintJobId() { |
| 40 |
this(UUID.randomUUID().toString()); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public PrintJobId(@NonNull String value) { |
| 51 |
mValue = value; |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public int hashCode() { |
| 56 |
final int prime = 31; |
| 57 |
int result = 1; |
| 58 |
result = prime * result + mValue.hashCode(); |
| 59 |
return result; |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public boolean equals(@Nullable Object obj) { |
| 64 |
if (this == obj) { |
| 65 |
return true; |
| 66 |
} |
| 67 |
if (obj == null) { |
| 68 |
return false; |
| 69 |
} |
| 70 |
if (getClass() != obj.getClass()) { |
| 71 |
return false; |
| 72 |
} |
| 73 |
PrintJobId other = (PrintJobId) obj; |
| 74 |
if (!mValue.equals(other.mValue)) { |
| 75 |
return false; |
| 76 |
} |
| 77 |
return true; |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public void writeToParcel(Parcel parcel, int flags) { |
| 82 |
parcel.writeString(mValue); |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public int describeContents() { |
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public @NonNull String flattenToString() { |
| 98 |
return mValue; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
public static @NonNull PrintJobId unflattenFromString(@NonNull String string) { |
| 110 |
return new PrintJobId(string); |
| 111 |
} |
| 112 |
|
| 113 |
public static final @android.annotation.NonNull Parcelable.Creator<PrintJobId> CREATOR = |
| 114 |
new Parcelable.Creator<PrintJobId>() { |
| 115 |
@Override |
| 116 |
public PrintJobId createFromParcel(Parcel parcel) { |
| 117 |
return new PrintJobId(Preconditions.checkNotNull(parcel.readString())); |
| 118 |
} |
| 119 |
|
| 120 |
@Override |
| 121 |
public PrintJobId[] newArray(int size) { |
| 122 |
return new PrintJobId[size]; |
| 123 |
} |
| 124 |
}; |
| 125 |
} |