@@ -46,27 +46,35 @@ class Annotation extends @annotation, Expr {
4646
4747 /**
4848 * Gets a value of an annotation element. This includes default values in case
49- * no explicit value is specified.
49+ * no explicit value is specified. For elements with an array value type this
50+ * might have an `ArrayInit` as result. To properly handle array values, prefer
51+ * the predicate `getAnArrayValue`.
5052 */
5153 Expr getAValue ( ) { filteredAnnotValue ( this , _, result ) }
5254
5355 /**
5456 * Gets the value of the annotation element with the specified `name`.
5557 * This includes default values in case no explicit value is specified.
58+ * For elements with an array value type this might have an `ArrayInit` as result.
59+ * To properly handle array values, prefer the predicate `getAnArrayValue`.
5660 */
5761 Expr getValue ( string name ) { filteredAnnotValue ( this , this .getAnnotationElement ( name ) , result ) }
5862
5963 /**
6064 * If the value type of the annotation element with the specified `name` is an enum type,
6165 * gets the enum constant used as value for that element. This includes default values in
6266 * case no explicit value is specified.
67+ *
68+ * If the element value type is an enum type array, use `getAnEnumConstantArrayValue`.
6369 */
6470 EnumConstant getEnumConstantValue ( string name ) { result = getValue ( name ) .( FieldRead ) .getField ( ) }
6571
6672 /**
6773 * If the value type of the annotation element with the specified `name` is `String`,
6874 * gets the string value used for that element. This includes default values in case no
6975 * explicit value is specified.
76+ *
77+ * If the element value type is a string array, use `getAStringArrayValue`.
7078 */
7179 string getStringValue ( string name ) {
7280 // Uses CompileTimeConstantExpr instead of StringLiteral because value can
@@ -78,6 +86,8 @@ class Annotation extends @annotation, Expr {
7886 * If the value type of the annotation element with the specified `name` is `int`,
7987 * gets the int value used for that element. This includes default values in case no
8088 * explicit value is specified.
89+ *
90+ * If the element value type is an `int` array, use `getAnIntArrayValue`.
8191 */
8292 int getIntValue ( string name ) {
8393 // Uses CompileTimeConstantExpr instead of IntegerLiteral because value can
@@ -100,6 +110,8 @@ class Annotation extends @annotation, Expr {
100110 * If the annotation element with the specified `name` has a Java `Class` as value type,
101111 * gets the referenced type used as value for that element. This includes default values
102112 * in case no explicit value is specified.
113+ *
114+ * If the element value type is a `Class` array, use `getATypeArrayValue`.
103115 */
104116 Type getTypeValue ( string name ) { result = getValue ( name ) .( TypeLiteral ) .getReferencedType ( ) }
105117
@@ -125,6 +137,50 @@ class Annotation extends @annotation, Expr {
125137 */
126138 deprecated Expr getAValue ( string name ) { result = getAnArrayValue ( name ) }
127139
140+ /**
141+ * Gets a value of the annotation element with the specified `name`, which must be declared as an enum
142+ * type array. This includes default values in case no explicit value is specified.
143+ *
144+ * If the annotation element is defined with an array initializer, then the result will be one of the
145+ * elements of that array. Otherwise, the result will be the single expression defined for the value.
146+ */
147+ EnumConstant getAnEnumConstantArrayValue ( string name ) {
148+ result = this .getAnArrayValue ( name ) .( FieldRead ) .getField ( )
149+ }
150+
151+ /**
152+ * Gets a value of the annotation element with the specified `name`, which must be declared as a string
153+ * array. This includes default values in case no explicit value is specified.
154+ *
155+ * If the annotation element is defined with an array initializer, then the result will be one of the
156+ * elements of that array. Otherwise, the result will be the single expression defined for the value.
157+ */
158+ string getAStringArrayValue ( string name ) {
159+ result = this .getAnArrayValue ( name ) .( CompileTimeConstantExpr ) .getStringValue ( )
160+ }
161+
162+ /**
163+ * Gets a value of the annotation element with the specified `name`, which must be declared as an `int`
164+ * array. This includes default values in case no explicit value is specified.
165+ *
166+ * If the annotation element is defined with an array initializer, then the result will be one of the
167+ * elements of that array. Otherwise, the result will be the single expression defined for the value.
168+ */
169+ int getAnIntArrayValue ( string name ) {
170+ result = this .getAnArrayValue ( name ) .( CompileTimeConstantExpr ) .getIntValue ( )
171+ }
172+
173+ /**
174+ * Gets a value of the annotation element with the specified `name`, which must be declared as a `Class`
175+ * array. This includes default values in case no explicit value is specified.
176+ *
177+ * If the annotation element is defined with an array initializer, then the result will be one of the
178+ * elements of that array. Otherwise, the result will be the single expression defined for the value.
179+ */
180+ Type getATypeArrayValue ( string name ) {
181+ result = this .getAnArrayValue ( name ) .( TypeLiteral ) .getReferencedType ( )
182+ }
183+
128184 /**
129185 * Gets the value at a given index of the annotation element with the specified `name`, which must be
130186 * declared as an array type. This includes default values in case no explicit value is specified.
0 commit comments