1 /* 2 * Copyright (C) 2023 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.car.occupantconnection; 17 18 import android.annotation.NonNull; 19 import android.text.TextUtils; 20 21 import java.util.Objects; 22 23 /** A class used to identify a receiver endpoint. */ 24 final class ReceiverEndpointId { 25 26 /** Indicates which client this endpoint is in. */ 27 public final ClientId clientId; 28 29 /** 30 * The ID of this endpoint. The ID is specified by the client app via {@link 31 * android.car.occupantconnection.CarOccupantConnectionManager#registerReceiver}. 32 */ 33 public final String endpointId; 34 ReceiverEndpointId(@onNull ClientId clientId, @NonNull String endpointId)35 ReceiverEndpointId(@NonNull ClientId clientId, @NonNull String endpointId) { 36 this.clientId = Objects.requireNonNull(clientId, "clientId cannot be null"); 37 this.endpointId = Objects.requireNonNull(endpointId, "endpointId cannot be null"); 38 } 39 40 @Override equals(Object o)41 public boolean equals(Object o) { 42 if (this == o) { 43 return true; 44 } 45 if (!(o instanceof ReceiverEndpointId)) { 46 return false; 47 } 48 ReceiverEndpointId other = (ReceiverEndpointId) o; 49 return clientId.equals(other.clientId) 50 && TextUtils.equals(endpointId, other.endpointId); 51 } 52 53 @Override hashCode()54 public int hashCode() { 55 return Objects.hash(clientId, endpointId); 56 } 57 58 @Override toString()59 public String toString() { 60 return "ReceiverEndpointId[clientId=" + clientId + ", endpointId=" + endpointId + "]"; 61 } 62 } 63