01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.core.ext.typeinfo;
17:
18: import java.lang.annotation.Annotation;
19:
20: /**
21: * Interface implemented by elements that can have annotations. This interface
22: * is a departure for GWT in that it used types declared in the
23: * java.lang.annotation package instead of types declared as part of this
24: * typeinfo package. This reflects a compromise between a pure
25: * {@link TypeOracle} model and one that is more useful to developers.
26: */
27: public interface HasAnnotations {
28: /**
29: * Returns an instance of the specified annotation type if it is present on
30: * this element or <code>null</code> if it is not.
31: *
32: * @param annotationClass annotation type to search for
33: * @return instance of the specified annotation type if it is present on this
34: * element or <code>null</code> if it is not
35: */
36: <T extends Annotation> T getAnnotation(Class<T> annotationClass);
37:
38: /**
39: * Returns all annotations that are declared or inherited by this element.
40: *
41: * @return annotations that are declared or inherited by this element
42: */
43: Annotation[] getAnnotations();
44:
45: /**
46: * Returns annotations that are declared on this element.
47: *
48: * @return annotations that are declared on this element
49: */
50: Annotation[] getDeclaredAnnotations();
51:
52: /**
53: * Returns <code>true</code> if this item has an annotation of the specified
54: * type.
55: *
56: * @param annotationClass
57: *
58: * @return <code>true</code> if this item has an annotation of the specified
59: * type
60: */
61: boolean isAnnotationPresent(
62: Class<? extends Annotation> annotationClass);
63: }
|