18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.lang.model.element;
27
28
29 import java.lang.annotation.Annotation;
30 import java.lang.annotation.AnnotationTypeMismatchException;
31 import java.lang.annotation.IncompleteAnnotationException;
32 import java.util.List;
33 import java.util.Set;
34
35 import javax.lang.model.type.*;
36 import javax.lang.model.util.*;
37
38
39 /**
40 * Represents a program element such as a module, package, class, or method.
41 * Each element represents a static, language-level construct
42 * (and not, for example, a runtime construct of the virtual machine).
43 *
44 * <p> Elements should be compared using the {@link #equals(Object)}
45 * method. There is no guarantee that any particular element will
46 * always be represented by the same object.
47 *
48 * <p> To implement operations based on the class of an {@code
49 * Element} object, either use a {@linkplain ElementVisitor visitor} or
50 * use the result of the {@link #getKind} method. Using {@code
51 * instanceof} is <em>not</em> necessarily a reliable idiom for
52 * determining the effective class of an object in this modeling
53 * hierarchy since an implementation may choose to have a single object
54 * implement multiple {@code Element} subinterfaces.
55 *
56 * @author Joseph D. Darcy
57 * @author Scott Seligman
58 * @author Peter von der Ahé
251 * <i>not</i> be expected to be equal even if "the same"
252 * element is being modeled; this is analogous to the inequality
253 * of {@code Class} objects for the same class file loaded through
254 * different class loaders.
255 *
256 * @param obj the object to be compared with this element
257 * @return {@code true} if the specified object represents the same
258 * element as this
259 */
260 @Override
261 boolean equals(Object obj);
262
263 /**
264 * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
265 *
266 * @see #equals
267 */
268 @Override
269 int hashCode();
270
271
272 /**
273 * {@inheritDoc}
274 *
275 * <p> To get inherited annotations as well, use {@link
276 * Elements#getAllAnnotationMirrors(Element)
277 * getAllAnnotationMirrors}.
278 *
279 * @since 1.6
280 */
281 @Override
282 List<? extends AnnotationMirror> getAnnotationMirrors();
283
284 /**
285 * {@inheritDoc}
286 * @since 1.6
287 */
288 @Override
289 <A extends Annotation> A getAnnotation(Class<A> annotationType);
290
291 /**
292 * Applies a visitor to this element.
293 *
294 * @param <R> the return type of the visitor's methods
295 * @param <P> the type of the additional parameter to the visitor's methods
296 * @param v the visitor operating on this element
297 * @param p additional parameter to the visitor
298 * @return a visitor-specified result
299 */
300 <R, P> R accept(ElementVisitor<R, P> v, P p);
301 }
|
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.lang.model.element;
27
28
29 import java.lang.annotation.Annotation;
30 import java.lang.annotation.AnnotationTypeMismatchException;
31 import java.lang.annotation.IncompleteAnnotationException;
32 import java.util.List;
33 import java.util.Set;
34
35 import javax.lang.model.type.*;
36 import javax.lang.model.util.*;
37
38 /**
39 * Represents a program element such as a module, package, class, or method.
40 * Each element represents a static, language-level construct
41 * (and not, for example, a runtime construct of the virtual machine).
42 *
43 * <p> Elements should be compared using the {@link #equals(Object)}
44 * method. There is no guarantee that any particular element will
45 * always be represented by the same object.
46 *
47 * <p> To implement operations based on the class of an {@code
48 * Element} object, either use a {@linkplain ElementVisitor visitor} or
49 * use the result of the {@link #getKind} method. Using {@code
50 * instanceof} is <em>not</em> necessarily a reliable idiom for
51 * determining the effective class of an object in this modeling
52 * hierarchy since an implementation may choose to have a single object
53 * implement multiple {@code Element} subinterfaces.
54 *
55 * @author Joseph D. Darcy
56 * @author Scott Seligman
57 * @author Peter von der Ahé
250 * <i>not</i> be expected to be equal even if "the same"
251 * element is being modeled; this is analogous to the inequality
252 * of {@code Class} objects for the same class file loaded through
253 * different class loaders.
254 *
255 * @param obj the object to be compared with this element
256 * @return {@code true} if the specified object represents the same
257 * element as this
258 */
259 @Override
260 boolean equals(Object obj);
261
262 /**
263 * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
264 *
265 * @see #equals
266 */
267 @Override
268 int hashCode();
269
270 /**
271 * {@inheritDoc}
272 *
273 * <p>To get inherited annotations as well, use {@link
274 * Elements#getAllAnnotationMirrors(Element)
275 * getAllAnnotationMirrors}.
276 *
277 * <p>Note that any annotations returned by this method are
278 * declaration annotations.
279 *
280 * @since 1.6
281 */
282 @Override
283 List<? extends AnnotationMirror> getAnnotationMirrors();
284
285 /**
286 * {@inheritDoc}
287 *
288 * <p>Note that any annotation returned by this method is a
289 * declaration annotation.
290 *
291 * @since 1.6
292 */
293 @Override
294 <A extends Annotation> A getAnnotation(Class<A> annotationType);
295
296 /**
297 * {@inheritDoc}
298 *
299 * <p>Note that any annotations returned by this method are
300 * declaration annotations.
301 *
302 * @since 8
303 */
304 @Override
305 <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
306
307 /**
308 * Applies a visitor to this element.
309 *
310 * @param <R> the return type of the visitor's methods
311 * @param <P> the type of the additional parameter to the visitor's methods
312 * @param v the visitor operating on this element
313 * @param p additional parameter to the visitor
314 * @return a visitor-specified result
315 */
316 <R, P> R accept(ElementVisitor<R, P> v, P p);
317 }
|