-
Notifications
You must be signed in to change notification settings - Fork 78
/
MethodInfo.java
121 lines (105 loc) · 3.94 KB
/
MethodInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package jakarta.enterprise.lang.model.declarations;
import jakarta.enterprise.lang.model.types.Type;
import jakarta.enterprise.lang.model.types.TypeVariable;
import java.util.List;
/**
* A method or a constructor, {@linkplain #declaringClass() declared} in some class.
*
* @since 4.0
*/
public interface MethodInfo extends DeclarationInfo {
/**
* Returns the name of this method. In case of constructors, returns the binary name of the declaring class.
*
* @return the name of this method, never {@code null}
*/
String name();
/**
* Returns a list of {@linkplain ParameterInfo parameters} declared or implicitly declared on this method.
*
* @return immutable list of {@linkplain ParameterInfo parameterts}, never {@code null}
*/
List<ParameterInfo> parameters();
/**
* Returns the return type of this method. In case of constructors, returns the type of the declaring class.
*
* @return the return type of this method, never {@code null}
*/
Type returnType();
/**
* Returns the {@linkplain Type type} of the receiver parameter declared by this method.
* Returns {@code null} if this method cannot declare a receiver parameter; that is, if this method
* is {@code static} or is a constructor of a top-level class or a {@code static} nested class.
* If this method may declare a receiver parameter but does not, returns a {@link Type} with no annotations.
*
* @return the type of the receiver parameter declared by this method, with or without annotations,
* or {@code null} if this method cannot declare a receiver parameter
*/
Type receiverType();
/**
* Returns a list of {@linkplain Type exception types} that are declared to be thrown by this method.
* Returns an empty list if this method does not declare any exception.
*
* @return immutable list of {@linkplain Type exception types}, never {@code null}
*/
List<Type> throwsTypes();
/**
* Returns a list of {@linkplain TypeVariable type parameters} declared on this method.
* Returns an empty list if this method is not generic and so does not declare type parameters.
*
* @return immutable list of {@linkplain TypeVariable type parameters}, never {@code null}
*/
List<TypeVariable> typeParameters();
/**
* Returns whether this method is, in fact, a constructor.
*
* @return whether this method is, in fact, a constructor
*/
boolean isConstructor();
/**
* Returns whether this method is {@code static}.
*
* @return whether this method is {@code static}.
*/
boolean isStatic();
/**
* Returns whether this method is abstract.
* <p>
* A {@code static} method is never abstract.
* An instance method declared on a plain class or an enum is abstract if declared {@code abstract}.
* An instance method declared on an interface is abstract unless declared {@code default}.
* An instance method declared on an annotation type is always abstract.
* An instance method declared on a record type is never abstract.
*
* @return whether this method is {@code abstract}.
*/
boolean isAbstract();
/**
* Returns whether this method is {@code final}.
*
* @return whether this method is {@code final}.
*/
boolean isFinal();
/**
* Returns the modifiers of this method as an {@code int}.
* Use {@link java.lang.reflect.Modifier Modifier} to inspect the value.
*
* @return the modifiers of this method
*/
int modifiers();
/**
* Returns the {@linkplain ClassInfo class} that declares this method.
*
* @return the {@linkplain ClassInfo class} that declares this method, never {@code null}
*/
ClassInfo declaringClass();
// ---
@Override
default Kind kind() {
return Kind.METHOD;
}
@Override
default MethodInfo asMethod() {
return this;
}
}