1 /* |
1 /* |
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
147 * @see MirroredTypesException |
147 * @see MirroredTypesException |
148 */ |
148 */ |
149 <A extends Annotation> A getAnnotation(Class<A> annotationType); |
149 <A extends Annotation> A getAnnotation(Class<A> annotationType); |
150 |
150 |
151 /** |
151 /** |
|
152 * Returns an array of all of this element's annotation for the |
|
153 * specified type if such annotations are present, else an empty |
|
154 * array. The annotation may be either inherited or directly |
|
155 * present on this element. This method will look through a container |
|
156 * annotation (if present) if the supplied annotation type is |
|
157 * repeatable. |
|
158 * |
|
159 * <p> The annotations returned by this method could contain an element |
|
160 * whose value is of type {@code Class}. |
|
161 * This value cannot be returned directly: information necessary to |
|
162 * locate and load a class (such as the class loader to use) is |
|
163 * not available, and the class might not be loadable at all. |
|
164 * Attempting to read a {@code Class} object by invoking the relevant |
|
165 * method on the returned annotation |
|
166 * will result in a {@link MirroredTypeException}, |
|
167 * from which the corresponding {@link TypeMirror} may be extracted. |
|
168 * Similarly, attempting to read a {@code Class[]}-valued element |
|
169 * will result in a {@link MirroredTypesException}. |
|
170 * |
|
171 * <blockquote> |
|
172 * <i>Note:</i> This method is unlike others in this and related |
|
173 * interfaces. It operates on runtime reflective information — |
|
174 * representations of annotation types currently loaded into the |
|
175 * VM — rather than on the representations defined by and used |
|
176 * throughout these interfaces. Consequently, calling methods on |
|
177 * the returned annotation object can throw many of the exceptions |
|
178 * that can be thrown when calling methods on an annotation object |
|
179 * returned by core reflection. This method is intended for |
|
180 * callers that are written to operate on a known, fixed set of |
|
181 * annotation types. |
|
182 * </blockquote> |
|
183 * |
|
184 * @param <A> the annotation type |
|
185 * @param annotationType the {@code Class} object corresponding to |
|
186 * the annotation type |
|
187 * @return this element's annotations for the specified annotation |
|
188 * type if present on this element, else an empty array |
|
189 * |
|
190 * @see #getAnnotationMirrors() |
|
191 * @see #getAnnotation() |
|
192 * @see java.lang.reflect.AnnotatedElement#getAnnotations |
|
193 * @see EnumConstantNotPresentException |
|
194 * @see AnnotationTypeMismatchException |
|
195 * @see IncompleteAnnotationException |
|
196 * @see MirroredTypeException |
|
197 * @see MirroredTypesException |
|
198 */ |
|
199 <A extends Annotation> A[] getAnnotations(Class<A> annotationType); |
|
200 |
|
201 /** |
152 * Returns the modifiers of this element, excluding annotations. |
202 * Returns the modifiers of this element, excluding annotations. |
153 * Implicit modifiers, such as the {@code public} and {@code static} |
203 * Implicit modifiers, such as the {@code public} and {@code static} |
154 * modifiers of interface members, are included. |
204 * modifiers of interface members, are included. |
155 * |
205 * |
156 * @return the modifiers of this element, or an empty set if there are none |
206 * @return the modifiers of this element, or an empty set if there are none |