5
5
import javax .lang .model .util .ElementFilter ;
6
6
import javax .lang .model .util .Elements ;
7
7
import javax .lang .model .util .Types ;
8
- import java .lang .reflect .ParameterizedType ;
9
8
import java .lang .reflect .Type ;
10
9
import java .util .List ;
11
10
@@ -27,7 +26,7 @@ public static String getMethodSignature(final ExecutableElement methodDoc) {
27
26
28
27
/**
29
28
* Checks if an element has a given modifier
30
- *
29
+ *
31
30
* @param element the element to check
32
31
* @param modifier the modifier we are looking for in the element
33
32
* @return true if the modifier is present in the element declaration, false otherwise
@@ -38,7 +37,7 @@ public static boolean hasModifier(final Element element, final Modifier modifier
38
37
39
38
/**
40
39
* {@return the list of fields from a given class element}
41
- *
40
+ *
42
41
* @param classElement the class to get its fields
43
42
*/
44
43
public static List <VariableElement > getFields (final TypeElement classElement ) {
@@ -47,7 +46,7 @@ public static List<VariableElement> getFields(final TypeElement classElement) {
47
46
48
47
/**
49
48
* {@return the list of constructors from a given class element}
50
- *
49
+ *
51
50
* @param classElement the class to get its constructors
52
51
*/
53
52
public static List <ExecutableElement > getConstructors (final TypeElement classElement ) {
@@ -56,7 +55,7 @@ public static List<ExecutableElement> getConstructors(final TypeElement classEle
56
55
57
56
/**
58
57
* {@return the list of methods from a given class element}
59
- *
58
+ *
60
59
* @param classElement the class to get its methods
61
60
*/
62
61
public static List <ExecutableElement > getMethods (final TypeElement classElement ) {
@@ -65,7 +64,7 @@ public static List<ExecutableElement> getMethods(final TypeElement classElement)
65
64
66
65
/**
67
66
* {@return a type as WildcardType if it is such a type, or null otherwise}
68
- *
67
+ *
69
68
* @param typeMirror the type to get it as a wildcard type
70
69
*/
71
70
public static WildcardType getWildcardType (final TypeMirror typeMirror ) {
@@ -77,14 +76,14 @@ public static WildcardType getWildcardType(final TypeMirror typeMirror) {
77
76
}
78
77
79
78
/**
80
- * {@return a type as ParameterizedType if it is such a type , or null otherwise}
81
- *
79
+ * {@return a type as DeclaredType if the typeMirror has type arguments ( such a List<String>) , or null otherwise}
80
+ *
82
81
* @param typeMirror the type to get it as a wildcard type
83
82
*/
84
- public static ParameterizedType getParameterizedType (TypeMirror typeMirror ) {
83
+ public static DeclaredType getParameterizedType (TypeMirror typeMirror ) {
85
84
if (typeMirror instanceof DeclaredType declaredType ) {
86
- if (!declaredType .getTypeArguments ().isEmpty () && declaredType instanceof ParameterizedType ) {
87
- return ( ParameterizedType ) declaredType ;
85
+ if (!declaredType .getTypeArguments ().isEmpty ()) {
86
+ return declaredType ;
88
87
}
89
88
}
90
89
@@ -97,7 +96,7 @@ public static boolean isArray(final TypeMirror typeMirror) {
97
96
98
97
/**
99
98
* {@return the dimension of type that represents an array, or an empty string if the type is not an array}
100
- *
99
+ *
101
100
* @param typeMirror the array type to get its dimension
102
101
*/
103
102
public static String getArrayDimension (final TypeMirror typeMirror ) {
@@ -112,7 +111,7 @@ public static String getArrayDimension(final TypeMirror typeMirror) {
112
111
113
112
/**
114
113
* {@return a TypeMirror for a given Type instance}
115
- *
114
+ *
116
115
* @param type the {@link Type} instance to get a {@link TypeMirror}
117
116
*/
118
117
public TypeMirror getTypeMirror (final Type type ) {
0 commit comments