• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 com.android.mtp;
18 
19 import java.util.Objects;
20 import static com.android.mtp.MtpDatabaseConstants.DocumentType;
21 
22 /**
23  * Static utilities for ID.
24  */
25 class Identifier {
26     final int mDeviceId;
27     final int mStorageId;
28     final int mObjectHandle;
29     final String mDocumentId;
30     final @DocumentType int mDocumentType;
31 
Identifier(int deviceId, int storageId, int objectHandle, String documentId, @DocumentType int documentType)32     Identifier(int deviceId, int storageId, int objectHandle, String documentId,
33             @DocumentType int documentType) {
34         mDeviceId = deviceId;
35         mStorageId = storageId;
36         mObjectHandle = objectHandle;
37         mDocumentId = documentId;
38         mDocumentType = documentType;
39     }
40 
41     @Override
equals(Object obj)42     public boolean equals(Object obj) {
43         if (!(obj instanceof Identifier))
44             return false;
45         final Identifier other = (Identifier) obj;
46         return mDeviceId == other.mDeviceId && mStorageId == other.mStorageId &&
47                 mObjectHandle == other.mObjectHandle && mDocumentId.equals(other.mDocumentId);
48     }
49 
50     @Override
hashCode()51     public int hashCode() {
52         return Objects.hash(mDeviceId, mStorageId, mObjectHandle, mDocumentId);
53     }
54 
55     @Override
toString()56     public String toString() {
57         final StringBuilder builder = new StringBuilder();
58         builder.append("Identifier { ");
59 
60         builder.append("mDeviceId: ");
61         builder.append(mDeviceId);
62         builder.append(", ");
63 
64         builder.append("mStorageId: ");
65         builder.append(mStorageId);
66         builder.append(", ");
67 
68         builder.append("mObjectHandle: ");
69         builder.append(mObjectHandle);
70         builder.append(", ");
71 
72         builder.append("mDocumentId: ");
73         builder.append(mDocumentId);
74         builder.append(", ");
75 
76         builder.append("mDocumentType: ");
77         builder.append(mDocumentType);
78         builder.append(" }");
79         return builder.toString();
80     }
81 }
82