001 package edu.rice.cs.cunit.subAnnot;
002
003 import java.lang.annotation.Annotation;
004 import java.lang.reflect.Proxy;
005 import java.util.List;
006 import java.util.ArrayList;
007
008 /**
009 * Interface for annotated elements supporting annotations with subtyping.
010 *
011 * @author Mathias Ricken
012 */
013 public interface AnnotatedElementEx {
014 /**
015 * Returns true if the class file was found and additional information is available beyond what
016 * Java's Class class might return.
017 * @return true if class file was found.
018 */
019 public boolean isAvailable();
020
021 /**
022 * Returns true if an annotation for the specified type or one of its subtypes is present on this element,
023 * else false. This method is designed primarily for convenient access to marker annotations.
024 * @param c class
025 * @return true if present
026 */
027 public boolean isAnnotationPresent(ClassEx<? extends Annotation> c);
028
029 /**
030 * Returns true if an annotation for the specified type or one of its subtypes is present on this element,
031 * else false. This method is designed primarily for convenient access to marker annotations.
032 * @param c class
033 * @return true if present
034 */
035 public boolean isAnnotationPresent(Class<? extends Annotation> c);
036
037 /**
038 * Return an array of the annotations attached to the element that are subclasses of the specified class.
039 * @param c class
040 * @return array of annotations
041 */
042 public <A extends Annotation> List<A> getAnnotations(ClassEx<A> c);
043
044 /**
045 * Return an array of the annotations attached to the element that are subclasses of the specified class.
046 * @param c class
047 * @return array of annotations
048 */
049 @SuppressWarnings("unchecked")
050 public <A extends Annotation> List<A> getAnnotations(Class<A> c);
051
052 /**
053 * Return an array of all annotations attached to the element.
054 * @return array of annotations
055 */
056 public Annotation[] getAnnotations();
057
058 /**
059 * Returns true if an annotation for the specified type or one of its subtypes is present on this element,
060 * else false. This method is designed primarily for convenient access to marker annotations.
061 * Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.
062 * @param c class
063 * @return true if present
064 */
065 public boolean isDeclaredAnnotationPresent(ClassEx<? extends Annotation> c);
066
067 /**
068 * Returns true if an annotation for the specified type or one of its subtypes is present on this element,
069 * else false. This method is designed primarily for convenient access to marker annotations.
070 * Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.
071 * @param c class
072 * @return true if present
073 */
074 public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> c);
075
076 /**
077 * Return an array of the annotations attached to the element that are subclasses of the specified class.
078 * Contrary to getAnnotations, this does not consider annotations inherited from superclasses.
079 * @param c class
080 * @return array of annotations
081 */
082 public <A extends Annotation> List<A> getDeclaredAnnotations(ClassEx<A> c);
083
084 /**
085 * Return an array of the annotations attached to the element that are subclasses of the specified class.
086 * Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.
087 * @param c class
088 * @return array of annotations
089 */
090 @SuppressWarnings("unchecked")
091 public <A extends Annotation> List<A> getDeclaredAnnotations(Class<A> c);
092
093 /**
094 * Return an array of all annotations attached directly to the element.
095 * Contrary to getAnnotations(), this does not consider annotations inherited from superclasses.
096 * @return array of annotations
097 */
098 public Annotation[] getDeclaredAnnotations();
099 }