1 /* <lambda>null2 * Copyright (C) 2018 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 18 19 import com.android.tools.metalava.model.visitors.ItemVisitor 20 import com.android.tools.metalava.model.visitors.TypeVisitor 21 22 interface PropertyItem : MemberItem { 23 /** The type of this property */ 24 override fun type(): TypeItem 25 26 override fun accept(visitor: ItemVisitor) { 27 if (visitor.skip(this)) { 28 return 29 } 30 31 visitor.visitItem(this) 32 visitor.visitProperty(this) 33 34 visitor.afterVisitProperty(this) 35 visitor.afterVisitItem(this) 36 } 37 38 override fun acceptTypes(visitor: TypeVisitor) { 39 if (visitor.skip(this)) { 40 return 41 } 42 43 val type = type() 44 visitor.visitType(type, this) 45 visitor.afterVisitType(type, this) 46 } 47 48 override fun hasNullnessInfo(): Boolean { 49 if (!requiresNullnessInfo()) { 50 return true 51 } 52 53 return modifiers.hasNullnessInfo() 54 } 55 56 override fun requiresNullnessInfo(): Boolean { 57 if (type().primitive) { 58 return false 59 } 60 61 return true 62 } 63 64 companion object { 65 val comparator: java.util.Comparator<PropertyItem> = Comparator { a, b -> a.name().compareTo(b.name()) } 66 } 67 }