1 /*
2  * Copyright 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.privacysandbox.ads.adservices.topics
18 
19 import androidx.privacysandbox.ads.adservices.common.ExperimentalFeatures
20 import java.util.Objects
21 
22 /** Represent the result from the getTopics API. */
23 @OptIn(ExperimentalFeatures.Ext11OptIn::class)
24 class GetTopicsResponse
25 @ExperimentalFeatures.Ext11OptIn
26 constructor(
27     val topics: List<Topic>,
28     val encryptedTopics: List<EncryptedTopic>,
29 ) {
30     constructor(topics: List<Topic>) : this(topics, listOf())
31 
equalsnull32     override fun equals(other: Any?): Boolean {
33         if (this === other) return true
34         if (other !is GetTopicsResponse) return false
35         if (topics.size != other.topics.size || encryptedTopics.size != other.encryptedTopics.size)
36             return false
37         return HashSet(this.topics) == HashSet(other.topics) &&
38             HashSet(this.encryptedTopics) == HashSet(other.encryptedTopics)
39     }
40 
hashCodenull41     override fun hashCode(): Int {
42         return Objects.hash(topics, encryptedTopics)
43     }
44 
toStringnull45     override fun toString(): String {
46         return "GetTopicsResponse: Topics=$topics, EncryptedTopics=$encryptedTopics"
47     }
48 }
49