Java Code Examples for sun.reflect.annotation.AnnotationSupport#getDirectlyAndIndirectlyPresent()

The following examples show how to use sun.reflect.annotation.AnnotationSupport#getDirectlyAndIndirectlyPresent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Field.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 2
Source File: Parameter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 3
Source File: Parameter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 4
Source File: Parameter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 5
Source File: Parameter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 6
Source File: Field.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 7
Source File: Parameter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 8
Source File: Executable.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 9
Source File: Field.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 10
Source File: Executable.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 11
Source File: Field.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 12
Source File: Parameter.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws NullPointerException {@inheritDoc}
 */
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
}
 
Example 13
Source File: TypeVariableImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);
    return AnnotationSupport.getDirectlyAndIndirectlyPresent(mapAnnotations(getAnnotations()), annotationClass);
}
 
Example 14
Source File: TypeVariableImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);
    return AnnotationSupport.getDirectlyAndIndirectlyPresent(mapAnnotations(getAnnotations()), annotationClass);
}
 
Example 15
Source File: TypeVariableImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
    Objects.requireNonNull(annotationClass);
    return AnnotationSupport.getDirectlyAndIndirectlyPresent(mapAnnotations(getAnnotations()), annotationClass);
}
 
Example 16
Source File: AnnotatedElement.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: AnnotatedElement.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: AnnotatedElement.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: AnnotatedElement.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: AnnotatedElement.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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);
}