本文整理汇总了Java中sun.reflect.annotation.AnnotationSupport.getDirectlyAndIndirectlyPresent方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationSupport.getDirectlyAndIndirectlyPresent方法的具体用法?Java AnnotationSupport.getDirectlyAndIndirectlyPresent怎么用?Java AnnotationSupport.getDirectlyAndIndirectlyPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.reflect.annotation.AnnotationSupport
的用法示例。
在下文中一共展示了AnnotationSupport.getDirectlyAndIndirectlyPresent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotationsByType
import sun.reflect.annotation.AnnotationSupport; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
示例2: getAnnotationsByType
import sun.reflect.annotation.AnnotationSupport; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
示例3: getAnnotationsByType
import sun.reflect.annotation.AnnotationSupport; //导入方法依赖的package包/类
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getDirectlyAndIndirectlyPresent(mapAnnotations(getAnnotations()), annotationClass);
}
示例4: getDeclaredAnnotationsByType
import sun.reflect.annotation.AnnotationSupport; //导入方法依赖的package包/类
/**
* Returns this element's annotation(s) for the specified type if
* such annotations are either <em>directly present</em> or
* <em>indirectly present</em>. This method ignores inherited
* annotations.
*
* If there are no specified annotations directly or indirectly
* present on this element, the return value is an array of length
* 0.
*
* The difference between this method and {@link
* #getDeclaredAnnotation(Class)} is that this method detects if its
* argument is a <em>repeatable annotation type</em> (JLS 9.6), and if so,
* attempts to find one or more annotations of that type by "looking
* through" a container annotation if one is present.
*
* The caller of this method is free to modify the returned array; it will
* have no effect on the arrays returned to other callers.
*
* @implSpec The default implementation may call {@link
* #getDeclaredAnnotation(Class)} one or more times to find a
* directly present annotation and, if the annotation type is
* repeatable, to find a container annotation. If annotations of
* the annotation type {@code annotationClass} are found to be both
* directly and indirectly present, then {@link
* #getDeclaredAnnotations()} will get called to determine the
* order of the elements in the returned array.
*
* <p>Alternatively, the default implementation may call {@link
* #getDeclaredAnnotations()} a single time and the returned array
* examined for both directly and indirectly present
* annotations. The results of calling {@link
* #getDeclaredAnnotations()} are assumed to be consistent with the
* results of calling {@link #getDeclaredAnnotation(Class)}.
*
* @param <T> the type of the annotation to query for and return
* if directly or indirectly present
* @param annotationClass the Class object corresponding to the
* annotation type
* @return all this element's annotations for the specified annotation type if
* directly or indirectly present on this element, else an array of length zero
* @throws NullPointerException if the given annotation class is null
* @since 1.8
*/
default <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.
getDirectlyAndIndirectlyPresent(Arrays.stream(getDeclaredAnnotations()).
collect(Collectors.toMap(Annotation::annotationType,
Function.identity(),
((first,second) -> first),
LinkedHashMap::new)),
annotationClass);
}