Identifier.java revision 9e8a4fa78f5b9e3964dca84ad4047210d35c4013
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
17package com.android.mtp;
18
19import java.util.Objects;
20
21/**
22 * Static utilities for ID.
23 */
24class Identifier {
25    final static int DUMMY_HANDLE_FOR_ROOT = 0;
26
27    final int mDeviceId;
28    final int mStorageId;
29    final int mObjectHandle;
30    final String mDocumentId;
31
32    Identifier(int deviceId, int storageId, int objectHandle, String documentId) {
33        mDeviceId = deviceId;
34        mStorageId = storageId;
35        mObjectHandle = objectHandle;
36        mDocumentId = documentId;
37    }
38
39    @Override
40    public boolean equals(Object obj) {
41        if (!(obj instanceof Identifier))
42            return false;
43        final Identifier other = (Identifier)obj;
44        return mDeviceId == other.mDeviceId && mStorageId == other.mStorageId &&
45                mObjectHandle == other.mObjectHandle;
46    }
47
48    @Override
49    public int hashCode() {
50        return Objects.hash(mDeviceId, mStorageId, mObjectHandle, mDocumentId);
51    }
52}
53