src/share/classes/java/lang/reflect/Parameter.java

Print this page




 263         return getAnnotation(annotationClass);
 264     }
 265 
 266     /**
 267      * @throws NullPointerException {@inheritDoc}
 268      */
 269     public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
 270         // Only annotations on classes are inherited, for all other
 271         // objects getDeclaredAnnotations is the same as
 272         // getAnnotations.
 273         return getAnnotations(annotationClass);
 274     }
 275 
 276     /**
 277      * {@inheritDoc}
 278      */
 279     public Annotation[] getAnnotations() {
 280         return getDeclaredAnnotations();
 281     }
 282 
 283     /**
 284      * @throws NullPointerException {@inheritDoc}
 285      */
 286     public boolean isAnnotationPresent(
 287         Class<? extends Annotation> annotationClass) {
 288         return getAnnotation(annotationClass) != null;
 289     }
 290 
 291     private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
 292 
 293     private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
 294         if(null == declaredAnnotations) {
 295             declaredAnnotations =
 296                 new HashMap<Class<? extends Annotation>, Annotation>();
 297             Annotation[] ann = getDeclaredAnnotations();
 298             for(int i = 0; i < ann.length; i++)
 299                 declaredAnnotations.put(ann[i].annotationType(), ann[i]);
 300         }
 301         return declaredAnnotations;
 302     }
 303 
 304 }


 263         return getAnnotation(annotationClass);
 264     }
 265 
 266     /**
 267      * @throws NullPointerException {@inheritDoc}
 268      */
 269     public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
 270         // Only annotations on classes are inherited, for all other
 271         // objects getDeclaredAnnotations is the same as
 272         // getAnnotations.
 273         return getAnnotations(annotationClass);
 274     }
 275 
 276     /**
 277      * {@inheritDoc}
 278      */
 279     public Annotation[] getAnnotations() {
 280         return getDeclaredAnnotations();
 281     }
 282 








 283     private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
 284 
 285     private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
 286         if(null == declaredAnnotations) {
 287             declaredAnnotations =
 288                 new HashMap<Class<? extends Annotation>, Annotation>();
 289             Annotation[] ann = getDeclaredAnnotations();
 290             for(int i = 0; i < ann.length; i++)
 291                 declaredAnnotations.put(ann[i].annotationType(), ann[i]);
 292         }
 293         return declaredAnnotations;
 294     }
 295 
 296 }