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 17 package androidx.core.uwb.backend.impl.internal; 18 19 import androidx.annotation.Nullable; 20 21 import java.util.Objects; 22 23 /** Represents a UWB device. */ 24 public class UwbDevice { 25 26 private final UwbAddress mAddress; 27 28 /** Creates a new UwbDevice from a given address. */ createForAddress(byte[] address)29 public static UwbDevice createForAddress(byte[] address) { 30 return new UwbDevice(UwbAddress.fromBytes(address)); 31 } 32 UwbDevice(UwbAddress address)33 private UwbDevice(UwbAddress address) { 34 this.mAddress = address; 35 } 36 37 /** The device address (eg, MAC address). */ getAddress()38 public UwbAddress getAddress() { 39 return mAddress; 40 } 41 42 @Override equals(@ullable Object o)43 public boolean equals(@Nullable Object o) { 44 if (this == o) { 45 return true; 46 } 47 if (!(o instanceof UwbDevice)) { 48 return false; 49 } 50 UwbDevice uwbDevice = (UwbDevice) o; 51 return Objects.equals(mAddress, uwbDevice.mAddress); 52 } 53 54 @Override hashCode()55 public int hashCode() { 56 return Objects.hashCode(mAddress); 57 } 58 59 @Override toString()60 public String toString() { 61 return String.format("UwbDevice {%s}", mAddress); 62 } 63 } 64