< prev index next >

src/java.base/share/classes/java/lang/reflect/AnnotatedType.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  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 java.lang.reflect;
  27 


  28 /**
  29  * {@code AnnotatedType} represents the potentially annotated use of a type in
  30  * the program currently running in this VM. The use may be of any type in the
  31  * Java programming language, including an array type, a parameterized type, a
  32  * type variable, or a wildcard type.
  33  *
  34  * @since 1.8
  35  */
  36 public interface AnnotatedType extends AnnotatedElement {
  37 
  38     /**
  39      * Returns the potentially annotated type that this type is a member of, if
  40      * this type represents a nested type. For example, if this type is
  41      * {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
  42      *
  43      * <p>Returns {@code null} if this {@code AnnotatedType} represents a
  44      *     top-level type, or a local or anonymous class, or a primitive type, or
  45      *     void.
  46      *
  47      * <p>Returns {@code null} if this {@code AnnotatedType} is an instance of


  55      * @return an {@code AnnotatedType} object representing the potentially
  56      *     annotated type that this type is a member of, or {@code null}
  57      * @throws TypeNotPresentException if the owner type
  58      *     refers to a non-existent type declaration
  59      * @throws MalformedParameterizedTypeException if the owner type
  60      *     refers to a parameterized type that cannot be instantiated
  61      *     for any reason
  62      *
  63      * @since 9
  64      */
  65     default AnnotatedType getAnnotatedOwnerType() {
  66         return null;
  67     }
  68 
  69     /**
  70      * Returns the underlying type that this annotated type represents.
  71      *
  72      * @return the type this annotated type represents
  73      */
  74     public Type getType();














































  75 }


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  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 java.lang.reflect;
  27 
  28 import java.lang.annotation.Annotation;
  29 
  30 /**
  31  * {@code AnnotatedType} represents the potentially annotated use of a type in
  32  * the program currently running in this VM. The use may be of any type in the
  33  * Java programming language, including an array type, a parameterized type, a
  34  * type variable, or a wildcard type.
  35  *
  36  * @since 1.8
  37  */
  38 public interface AnnotatedType extends AnnotatedElement {
  39 
  40     /**
  41      * Returns the potentially annotated type that this type is a member of, if
  42      * this type represents a nested type. For example, if this type is
  43      * {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
  44      *
  45      * <p>Returns {@code null} if this {@code AnnotatedType} represents a
  46      *     top-level type, or a local or anonymous class, or a primitive type, or
  47      *     void.
  48      *
  49      * <p>Returns {@code null} if this {@code AnnotatedType} is an instance of


  57      * @return an {@code AnnotatedType} object representing the potentially
  58      *     annotated type that this type is a member of, or {@code null}
  59      * @throws TypeNotPresentException if the owner type
  60      *     refers to a non-existent type declaration
  61      * @throws MalformedParameterizedTypeException if the owner type
  62      *     refers to a parameterized type that cannot be instantiated
  63      *     for any reason
  64      *
  65      * @since 9
  66      */
  67     default AnnotatedType getAnnotatedOwnerType() {
  68         return null;
  69     }
  70 
  71     /**
  72      * Returns the underlying type that this annotated type represents.
  73      *
  74      * @return the type this annotated type represents
  75      */
  76     public Type getType();
  77 
  78     /**
  79      * {@inheritDoc}
  80      * <p>Any annotation returned by this method is a type annotation.
  81      * @throws NullPointerException {@inheritDoc}
  82      */
  83     @Override
  84     <T extends Annotation> T getAnnotation(Class<T> annotationClass);
  85 
  86     /**
  87      * {@inheritDoc}
  88      * <p>Any annotations returned by this method are type annotations.
  89      * @throws NullPointerException {@inheritDoc}
  90      */
  91     @Override
  92     public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass);
  93 
  94     /**
  95      * {@inheritDoc}
  96      * <p>Any annotations returned by this method are type annotations.
  97      */
  98     @Override
  99     public Annotation[] getAnnotations();
 100 
 101     /**
 102      * {@inheritDoc}
 103      * <p>Any annotation returned by this method is a type annotation.
 104      * @throws NullPointerException {@inheritDoc}
 105      */
 106     @Override
 107     public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass);
 108 
 109     /**
 110      * {@inheritDoc}
 111      * <p>Any annotations returned by this method are type annotations.
 112      * @throws NullPointerException {@inheritDoc}
 113      */
 114     @Override
 115     public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass);
 116 
 117     /**
 118      * {@inheritDoc}
 119      * <p>Any annotations returned by this method are type annotations.
 120      */
 121     @Override
 122     public Annotation[] getDeclaredAnnotations();
 123 }
< prev index next >