-
Notifications
You must be signed in to change notification settings - Fork 78
/
Types.java
118 lines (103 loc) · 4.37 KB
/
Types.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
package jakarta.enterprise.inject.build.compatible.spi;
import jakarta.enterprise.lang.model.declarations.ClassInfo;
import jakarta.enterprise.lang.model.types.ArrayType;
import jakarta.enterprise.lang.model.types.PrimitiveType;
import jakarta.enterprise.lang.model.types.Type;
import jakarta.enterprise.lang.model.types.VoidType;
// TODO move to jakarta.enterprise.lang.model.types? probably not, it doesn't model any part of Java language
/**
* A factory interface for creating instances of {@link Type}.
*/
public interface Types {
/**
* Returns the type for the given canonical name as defined by {@link Class#getCanonicalName()} or {@code null}
* if the type is not present on the classpath or cannot be resolved.
*
* @param name The name of the type, never {@code null}
* @return {@link Type} object representing the type or {@code null}
*/
Type forName(String name);
/**
* Returns a type from the given class literal.
*
* For example:
* <ul>
* <li>{@code of(void.class)}: same as {@code ofVoid()}</li>
* <li>{@code of(int.class)}: same as {@code ofPrimitive(PrimitiveKind.INT)}</li>
* <li>{@code of(String.class)}: same as {@code ofClass(... ClassInfo for String ...)}</li>
* <li>{@code of(int[].class)}: same as {@code ofArray(ofPrimitive(PrimitiveKind.INT), 1)}</li>
* <li>{@code of(String[][].class)}: same as {@code ofArray(ofClass(... ClassInfo for String ...), 2)}</li>
* </ul>
*
* @param clazz class literal
* @return {@link Type} object representing the given class literal
*/
Type of(Class<?> clazz);
/**
* @return An instance of {@link jakarta.enterprise.lang.model.types.VoidType}, never {@code null}
*/
VoidType ofVoid();
/**
* Returns a {@link PrimitiveType} for the given {@link jakarta.enterprise.lang.model.types.PrimitiveType.PrimitiveKind kind}.
* @param kind The kind, never {@code null}
* @return The {@link PrimitiveType}, never {@code null}
*/
PrimitiveType ofPrimitive(PrimitiveType.PrimitiveKind kind);
/**
* Returns a {@link Type} for the given {@link ClassInfo clazz}.
* @param clazz The {@link ClassInfo}, never {@code null}
* @return A {@link Type}, never {@code null}
*/
Type ofClass(ClassInfo clazz);
/**
* Returns an {@link ArrayType} for the given {@link Type componentType} and dimensions
* @param componentType The component {@link Type}
* @param dimensions The dimensions
* @return The {@link ArrayType}, never {@code null}
*/
ArrayType ofArray(Type componentType, int dimensions);
/**
* Returns a parameterized {@link Type} for the given type and type arguments.
*
* @param parameterizedType The type to parametrize, never {@code null}
* @param typeArguments Zero or more type arguments
* @return A potentially parameterized type, never {@code null}
*/
Type parameterized(Class<?> parameterizedType, Class<?>... typeArguments);
/**
* Returns a parameterized {@link Type} for the given type and type arguments.
*
* @param parameterizedType The type to parametrize, never {@code null}
* @param typeArguments Zero or more type arguments
* @return A potentially parameterized type, never {@code null}
*/
Type parameterized(Class<?> parameterizedType, Type... typeArguments);
/**
* Returns a parameterized {@link Type} for the given type and type arguments.
*
* @param parameterizedType The type to parametrize, never {@code null}
* @param typeArguments Zero or more type arguments
* @return A potentially parameterized type, never {@code null}
*/
Type parameterized(Type parameterizedType, Type... typeArguments);
/**
* Equivalent of {@code ? extends upperBound}.
*
* @param upperBound upper bound type
* @return {@link Type} object representing a wildcard type with given upper bound
*/
Type wildcardWithUpperBound(Type upperBound);
/**
* Equivalent of {@code ? super lowerBound}.
*
* @param lowerBound lower bound type
* @return {@link Type} object representing a wildcard type with given lower bound
*/
Type wildcardWithLowerBound(Type lowerBound);
/**
* Equivalent of {@code ?}.
*
* @return {@link Type} object representing an unbounded wildcard type
*/
Type wildcardUnbounded();
}