01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.lang.reflect;
19:
20: import java.lang.annotation.Annotation;
21:
22: /**
23: * An interface implemented an annotated element to enable reflective access to
24: * annotation information.
25: *
26: * @since 1.5
27: */
28: public interface AnnotatedElement {
29:
30: /**
31: * Gets the {@link Annotation} for this element for the annotation type
32: * passed, if it exists.
33: *
34: * @param annotationType
35: * The Class instance of the annotation to search for.
36: * @return The {@link Annotation} for this element or <code>null</code>.
37: * @throws NullPointerException
38: * if <code>annotationType</code> is <code>null</code>.
39: */
40: <T extends Annotation> T getAnnotation(Class<T> annotationType);
41:
42: /**
43: * Gets all {@link Annotation}s for this element.
44: *
45: * @return An array of {@link Annotation}s, which may be empty, but never
46: * <code>null</code>.
47: */
48: Annotation[] getAnnotations();
49:
50: /**
51: * Gets all {@link Annotation}s that are explicitly declared by this
52: * element (not inherited).
53: *
54: * @return An array of {@link Annotation}s, which may be empty, but never
55: * <code>null</code>.
56: */
57: Annotation[] getDeclaredAnnotations();
58:
59: /**
60: * Determines if this element has an annotation for the annotation type
61: * passed.
62: *
63: * @param annotationType
64: * The class instance of the annotation to search for.
65: * @return <code>true</code> if the annotation exists, otherwise
66: * <code>false</code>.
67: * @throws NullPointerException
68: * if <code>annotationType</code> is <code>null</code>.
69: */
70: boolean isAnnotationPresent(
71: Class<? extends Annotation> annotationType);
72: }
|