32
32
import jdk .internal .javac .PreviewFeature ;
33
33
34
34
/**
35
- * Models a key-value pair of an annotation.
35
+ * Models an element-value pair in the {@code element_value_pairs}
36
+ * table in the {@code annotation} structure defined in JVMS
37
+ * {@jvms 4.7.16} or the {@code type_annotation} structure defined
38
+ * in JVMS {@jvms 4.7.20}.
39
+ * <p>
40
+ * Two {@code AnnotationElement} objects should be compared using the
41
+ * {@link Object#equals(Object) equals} method.
36
42
*
37
43
* @see Annotation
38
44
* @see AnnotationValue
@@ -45,6 +51,12 @@ public sealed interface AnnotationElement
45
51
46
52
/**
47
53
* {@return the element name}
54
+ *
55
+ * @apiNote
56
+ * In Java source code, by convention, the name of the sole element in a
57
+ * single-element annotation interface is {@code value}. (JLS {@jls 9.6.1})
58
+ * This is the case for single-element annotations (JLS {@jls 9.7.3}) and
59
+ * container annotations for multiple annotations (JLS {@jls 9.6.3}).
48
60
*/
49
61
Utf8Entry name ();
50
62
@@ -54,7 +66,7 @@ public sealed interface AnnotationElement
54
66
AnnotationValue value ();
55
67
56
68
/**
57
- * {@return an annotation key -value pair}
69
+ * {@return an element -value pair}
58
70
* @param name the name of the key
59
71
* @param value the associated value
60
72
*/
@@ -64,7 +76,7 @@ static AnnotationElement of(Utf8Entry name,
64
76
}
65
77
66
78
/**
67
- * {@return an annotation key -value pair}
79
+ * {@return an element -value pair}
68
80
* @param name the name of the key
69
81
* @param value the associated value
70
82
*/
@@ -74,119 +86,131 @@ static AnnotationElement of(String name,
74
86
}
75
87
76
88
/**
77
- * {@return an annotation key -value pair for a class-valued annotation }
89
+ * {@return an element -value pair for a class-valued element }
78
90
* @param name the name of the key
79
91
* @param value the associated value
92
+ * @see AnnotationValue#ofClass(ClassDesc) AnnotationValue::ofClass
80
93
*/
81
94
static AnnotationElement ofClass (String name ,
82
95
ClassDesc value ) {
83
96
return of (name , AnnotationValue .ofClass (value ));
84
97
}
85
98
86
99
/**
87
- * {@return an annotation key -value pair for a string-valued annotation }
100
+ * {@return an element -value pair for a string-valued element }
88
101
* @param name the name of the key
89
102
* @param value the associated value
103
+ * @see AnnotationValue#ofString(String) AnnotationValue::ofString
90
104
*/
91
105
static AnnotationElement ofString (String name ,
92
106
String value ) {
93
107
return of (name , AnnotationValue .ofString (value ));
94
108
}
95
109
96
110
/**
97
- * {@return an annotation key -value pair for a long-valued annotation }
111
+ * {@return an element -value pair for a long-valued element }
98
112
* @param name the name of the key
99
113
* @param value the associated value
114
+ * @see AnnotationValue#ofLong(long) AnnotationValue::ofLong
100
115
*/
101
116
static AnnotationElement ofLong (String name ,
102
117
long value ) {
103
118
return of (name , AnnotationValue .ofLong (value ));
104
119
}
105
120
106
121
/**
107
- * {@return an annotation key -value pair for an int-valued annotation }
122
+ * {@return an element -value pair for an int-valued element }
108
123
* @param name the name of the key
109
124
* @param value the associated value
125
+ * @see AnnotationValue#ofInt(int) AnnotationValue::ofInt
110
126
*/
111
127
static AnnotationElement ofInt (String name ,
112
128
int value ) {
113
129
return of (name , AnnotationValue .ofInt (value ));
114
130
}
115
131
116
132
/**
117
- * {@return an annotation key -value pair for a char-valued annotation }
133
+ * {@return an element -value pair for a char-valued element }
118
134
* @param name the name of the key
119
135
* @param value the associated value
136
+ * @see AnnotationValue#ofChar(char) AnnotationValue::ofChar
120
137
*/
121
138
static AnnotationElement ofChar (String name ,
122
139
char value ) {
123
140
return of (name , AnnotationValue .ofChar (value ));
124
141
}
125
142
126
143
/**
127
- * {@return an annotation key -value pair for a short-valued annotation }
144
+ * {@return an element -value pair for a short-valued element }
128
145
* @param name the name of the key
129
146
* @param value the associated value
147
+ * @see AnnotationValue#ofShort(short) AnnotationValue::ofShort
130
148
*/
131
149
static AnnotationElement ofShort (String name ,
132
150
short value ) {
133
151
return of (name , AnnotationValue .ofShort (value ));
134
152
}
135
153
136
154
/**
137
- * {@return an annotation key -value pair for a byte-valued annotation }
155
+ * {@return an element -value pair for a byte-valued element }
138
156
* @param name the name of the key
139
157
* @param value the associated value
158
+ * @see AnnotationValue#ofByte(byte) AnnotationValue::ofByte
140
159
*/
141
160
static AnnotationElement ofByte (String name ,
142
- byte value ) {
161
+ byte value ) {
143
162
return of (name , AnnotationValue .ofByte (value ));
144
163
}
145
164
146
165
/**
147
- * {@return an annotation key -value pair for a boolean-valued annotation }
166
+ * {@return an element -value pair for a boolean-valued element }
148
167
* @param name the name of the key
149
168
* @param value the associated value
169
+ * @see AnnotationValue#ofBoolean(boolean) AnnotationValue::ofBoolean
150
170
*/
151
171
static AnnotationElement ofBoolean (String name ,
152
- boolean value ) {
172
+ boolean value ) {
153
173
return of (name , AnnotationValue .ofBoolean (value ));
154
174
}
155
175
156
176
/**
157
- * {@return an annotation key -value pair for a double-valued annotation }
177
+ * {@return an element -value pair for a double-valued element }
158
178
* @param name the name of the key
159
179
* @param value the associated value
180
+ * @see AnnotationValue#ofDouble(double) AnnotationValue::ofDouble
160
181
*/
161
182
static AnnotationElement ofDouble (String name ,
162
183
double value ) {
163
184
return of (name , AnnotationValue .ofDouble (value ));
164
185
}
165
186
166
187
/**
167
- * {@return an annotation key -value pair for a float-valued annotation }
188
+ * {@return an element -value pair for a float-valued element }
168
189
* @param name the name of the key
169
190
* @param value the associated value
191
+ * @see AnnotationValue#ofFloat(float) AnnotationValue::ofFloat
170
192
*/
171
193
static AnnotationElement ofFloat (String name ,
172
194
float value ) {
173
195
return of (name , AnnotationValue .ofFloat (value ));
174
196
}
175
197
176
198
/**
177
- * {@return an annotation key -value pair for an annotation-valued annotation }
199
+ * {@return an element -value pair for an annotation-valued element }
178
200
* @param name the name of the key
179
201
* @param value the associated value
202
+ * @see AnnotationValue#ofAnnotation AnnotationValue::ofAnnotation
180
203
*/
181
204
static AnnotationElement ofAnnotation (String name ,
182
205
Annotation value ) {
183
206
return of (name , AnnotationValue .ofAnnotation (value ));
184
207
}
185
208
186
209
/**
187
- * {@return an annotation key -value pair for an array-valued annotation }
210
+ * {@return an element -value pair for an array-valued element }
188
211
* @param name the name of the key
189
212
* @param values the associated values
213
+ * @see AnnotationValue#ofArray(AnnotationValue...) AnnotationValue::ofArray
190
214
*/
191
215
static AnnotationElement ofArray (String name ,
192
216
AnnotationValue ... values ) {
0 commit comments