• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 package com.android.server.uwb.util;
17 
18 import androidx.annotation.NonNull;
19 import androidx.annotation.Nullable;
20 
21 import java.util.Arrays;
22 
23 // TODO: encode/decode the ObjectIdentifier per X.660.
24 /**
25  * ObjectIdentifier for ADF OID.
26  */
27 public class ObjectIdentifier {
28     public final byte[] value;
29 
ObjectIdentifier(@onNull byte[] value)30     private ObjectIdentifier(@NonNull byte[] value) {
31         this.value = value;
32     }
33 
34     /**
35      * Convert the byte array to ObjectIdentifier.
36      */
fromBytes(@onNull byte[] bytes)37     public static ObjectIdentifier fromBytes(@NonNull byte[] bytes) {
38         return new ObjectIdentifier(bytes);
39     }
40 
41     @Override
equals(@ullable Object that)42     public boolean equals(@Nullable Object that) {
43         if (this == that) {
44             return true;
45         }
46         if (that == null || !(that instanceof ObjectIdentifier)) {
47             return false;
48         }
49 
50         return Arrays.equals(value, ((ObjectIdentifier) that).value);
51     }
52 
53     @Override
hashCode()54     public int hashCode() {
55         return Arrays.hashCode(value);
56     }
57 }
58