-
Notifications
You must be signed in to change notification settings - Fork 78
/
ClassInfo.java
205 lines (180 loc) · 6.98 KB
/
ClassInfo.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package jakarta.enterprise.lang.model.declarations;
import jakarta.enterprise.lang.model.types.Type;
import jakarta.enterprise.lang.model.types.TypeVariable;
import java.util.Collection;
import java.util.List;
/**
* A class. Five kinds of classes are distinguished:
* <ul>
* <li>plain classes</li>
* <li>interfaces</li>
* <li>enums (restricted kind of classes)</li>
* <li>annotations (specialized kind of interfaces)</li>
* <li>records (restricted kind of classes)</li>
* </ul>
*
* Classes are represented as isolated units. That is, if this class is nested, it is not possible
* to obtain the enclosing class. Similarly, it is not possible to obtain the set of classes
* nested in this class.
* <p>
* At the same time, it is possible to obtain the set of {@linkplain #constructors() constructors},
* {@linkplain #methods() methods} and {@linkplain #fields() fields} declared in this class.
* It is also possible to obtain the {@linkplain #packageInfo() package} this class is declared in.
*
* @since 4.0
*/
public interface ClassInfo extends DeclarationInfo {
/**
* Returns the binary name of this class, as defined by <cite>The Java™ Language Specification</cite>;
* in other words, the class name as returned by {@link Class#getName()}.
*
* @return binary name of this class, never {@code null}
*/
String name();
/**
* Returns the simple name of this class, as defined by <cite>The Java™ Language Specification</cite>;
* in other words, the class name as returned by {@link Class#getSimpleName()}.
*
* @return simple name of this class, never {@code null}
*/
String simpleName();
/**
* Returns the {@linkplain PackageInfo package} this class is part of.
* Returns {@code null} if this class is part of an unnamed package.
*
* @return this class's package, or {@code null} if this class is in an unnamed package
*/
PackageInfo packageInfo();
/**
* Returns a list of {@linkplain TypeVariable type parameters} declared on this class.
* Returns an empty list if this class is not generic and so does not declare type parameters.
*
* @return immutable list of this class's type parameters, never {@code null}
*/
List<TypeVariable> typeParameters();
/**
* Returns the {@linkplain Type type} of this class's superclass. Returns {@code null} if this class
* does not have a superclass; that is, if this class is {@code java.lang.Object} or an interface.
*
* @return the type of this class's superclass, or {@code null} if there's no superclass
*/
Type superClass();
/**
* Returns the {@linkplain ClassInfo declaration} of this class's superclass. Returns {@code null} if this class
* does not have a superclass; that is, if this class is {@code java.lang.Object} or an interface.
*
* @return the declaration of this class's superclass, or {@code null} if there's no superclass
*/
ClassInfo superClassDeclaration();
/**
* Returns a list of {@linkplain Type types} of this class's direct superinterfaces.
* Returns an empty list if this class has no direct superinterface.
*
* @return immutable list of types of this class's direct superinterfaces, never {@code null}
*/
List<Type> superInterfaces();
/**
* Returns a list of {@linkplain ClassInfo declarations} of this class's direct superinterfaces.
* Returns an empty list if this class has no direct superinterface.
*
* @return immutable list of declarations of this class's direct superinterfaces, never {@code null}
*/
List<ClassInfo> superInterfacesDeclarations();
/**
* Returns whether this class is a plain class. That is, not an interface,
* not an enum, not an annotation, and not a record.
*
* @return whether this class is a plain class
*/
boolean isPlainClass();
/**
* Returns whether this class is an interface.
*
* @return whether this class is an interface
*/
boolean isInterface();
/**
* Returns whether this class is an enum.
*
* @return whether this class is an enum
*/
boolean isEnum();
/**
* Returns whether this class is an annotation.
*
* @return whether this class is an annotation
*/
boolean isAnnotation();
/**
* Returns whether this class is a record.
*
* @return whether this class is a record
*/
boolean isRecord();
/**
* Returns whether this class is {@code abstract}.
*
* @return whether this class is {@code abstract}
*/
boolean isAbstract();
/**
* Returns whether this class is {@code final}.
*
* @return whether this class is {@code final}
*/
boolean isFinal();
/**
* Returns the modifiers of this class as an {@code int}.
* Use {@link java.lang.reflect.Modifier Modifier} to inspect the value.
*
* @return the modifiers of this class
*/
int modifiers();
/**
* Returns a collection of {@linkplain MethodInfo constructors} declared in this class.
* Constructors declared in direct or indirect superclasses are not included.
*
* @return immutable collection of constructors, never {@code null}
*/
Collection<MethodInfo> constructors();
/**
* Returns a collection of {@linkplain MethodInfo methods} declared in this class and all
* its superclasses up to and excluding {@code java.lang.Object}. This includes
* {@code private} methods declared by superclasses. Constructors are not included.
* <p>
* Also, {@code default} methods declared in all direct and indirect superinterfaces
* of this class are included. Abstract or {@code private} methods declared in interfaces
* are not included.
* TODO this rule about interface methods comes from current Weld implementation and needs more thinking
*
* @return immutable collection of methods, never {@code null}
*/
Collection<MethodInfo> methods();
/**
* Returns a collection of {@linkplain FieldInfo fields} declared in this class and all
* its superclasses up to and excluding {@code java.lang.Object}. This includes
* {@code private} fields declared in superclasses.
* <p>
* Fields declared in superinterfaces are not included.
* TODO this rule about interface fields comes from current Weld implementation and needs more thinking
*
* @return immutable collection of fields, never {@code null}
*/
Collection<FieldInfo> fields();
/**
* Returns a collection of {@linkplain RecordComponentInfo record components} declared in this class.
* If this class is not a record, returns an empty collection.
*
* @return immutable collection of record components, never {@code nul}
*/
Collection<RecordComponentInfo> recordComponents();
// ---
@Override
default Kind kind() {
return Kind.CLASS;
}
@Override
default ClassInfo asClass() {
return this;
}
}