• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 interface MemberItem : ClassContentItem, SelectableItem {
20     /**
21      * The name of this method/field. Constructors have the same name as their containing class'
22      * simple name
23      */
namenull24     fun name(): String
25 
26     /** Returns the internal name of the method, as seen in bytecode */
27     fun internalName(): String = name()
28 
29     /** The containing class */
30     @MetalavaApi override fun containingClass(): ClassItem
31 
32     override fun containingPackage(): PackageItem = containingClass().containingPackage()
33 
34     override fun parent(): ClassItem? = containingClass()
35 
36     override val effectivelyDeprecated: Boolean
37         get() = originallyDeprecated || containingClass().effectivelyDeprecated
38 
39     /**
40      * Returns true if this member is effectively final based on modifiers: it's either final
41      * itself, or implied to be final because its containing class is final or sealed.
42      */
43     fun isEffectivelyFinal(): Boolean {
44         return modifiers.isFinal() ||
45             containingClass().modifiers.isFinal() ||
46             containingClass().modifiers.isSealed()
47     }
48 
49     /**
50      * Returns whether the item can be overridden outside the API surface, which is true is it is
51      * not final and its containing class can be extended.
52      */
canBeExternallyOverriddennull53     fun canBeExternallyOverridden(): Boolean {
54         return !modifiers.isFinal() && containingClass().isExtensible()
55     }
56 }
57