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 17 package com.android.tools.metalava.model.turbine 18 19 import com.android.tools.metalava.model.BoundsTypeItem 20 import com.android.tools.metalava.model.DefaultModifierList 21 import com.android.tools.metalava.model.TypeNullability 22 import com.android.tools.metalava.model.TypeParameterItem 23 import com.android.tools.metalava.model.VariableTypeItem 24 import com.android.tools.metalava.model.type.DefaultTypeModifiers 25 import com.android.tools.metalava.model.type.DefaultVariableTypeItem 26 import com.android.tools.metalava.reporter.FileLocation 27 28 internal class TurbineTypeParameterItem( 29 codebase: TurbineBasedCodebase, 30 modifiers: DefaultModifierList, 31 private val name: String, 32 ) : 33 TurbineItem( 34 codebase, 35 FileLocation.UNKNOWN, 36 modifiers, 37 "", 38 ), 39 TypeParameterItem { 40 41 lateinit var bounds: List<BoundsTypeItem> 42 namenull43 override fun name() = name 44 45 // Java does not supports reified generics 46 override fun isReified(): Boolean = false 47 48 override fun typeBounds(): List<BoundsTypeItem> = bounds 49 50 override fun type(): VariableTypeItem { 51 return DefaultVariableTypeItem( 52 DefaultTypeModifiers.create(emptyList(), TypeNullability.UNDEFINED), 53 this 54 ) 55 } 56 equalsnull57 override fun equals(other: Any?): Boolean { 58 if (this === other) return true 59 if (other !is TypeParameterItem) return false 60 61 return name == other.name() 62 } 63 hashCodenull64 override fun hashCode(): Int { 65 return name.hashCode() 66 } 67 } 68