1 /*
2  * Copyright 2024 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.compose.integration.macrobenchmark.target.complexdifferenttypeslist.common
18 
19 class AdapterItemWrapper(
20     val type: BaseAdapterItemType,
21     val data: Any? = null,
22     var id: Any? = null,
23     val isSticky: Boolean = false
24 ) {
25 
hashCodenull26     override fun hashCode(): Int {
27         return if (id == null) {
28             31 * type.hashCode() + (data?.hashCode() ?: 0)
29         } else {
30             31 * type.hashCode() + id.hashCode()
31         }
32     }
33 
equalsnull34     override fun equals(other: Any?): Boolean {
35         if (this === other) return true
36         if (javaClass != other?.javaClass) return false
37 
38         other as AdapterItemWrapper
39 
40         if (type != other.type) return false
41         if (id != other.id) return false
42         if (data != other.data) return false
43         if (isSticky != other.isSticky) return false
44 
45         return true
46     }
47 
48     /** Returns a copy of [AdapterItemWrapper]. */
copynull49     fun copy(
50         type: BaseAdapterItemType = this.type,
51         data: Any? = this.data,
52         id: Any? = this.id,
53         isSticky: Boolean = this.isSticky
54     ): AdapterItemWrapper =
55         AdapterItemWrapper(type = type, data = data, id = id, isSticky = isSticky)
56 }
57