@Test public void shouldReturnAggregationAnnotationsOfAllObjectHierarchy() { final List<Environment> environments = (List<Environment>) ContainerObjectUtil.getAllAnnotations(FirstEnvironmentAnnotation.class, Environment.class); assertThat(environments.size(), is(2)); }
public static <T extends Annotation> List<T> getAllAnnotations(final Class<?> source, final Class<T> annotationClass) { return AccessController.doPrivileged((PrivilegedAction<List<T>>) () -> { List<T> annotations = new ArrayList<>(); Class<?> nextSource = source; while (nextSource != Object.class) { final T[] annotationsByType = nextSource.getAnnotationsByType(annotationClass); Collections.addAll(annotations, annotationsByType); nextSource = nextSource.getSuperclass(); } return annotations; }); }
ContainerObjectUtil { public static <T extends Annotation> List<T> getAllAnnotations(final Class<?> source, final Class<T> annotationClass) { return AccessController.doPrivileged((PrivilegedAction<List<T>>) () -> { List<T> annotations = new ArrayList<>(); Class<?> nextSource = source; while (nextSource != Object.class) { final T[] annotationsByType = nextSource.getAnnotationsByType(annotationClass); Collections.addAll(annotations, annotationsByType); nextSource = nextSource.getSuperclass(); } return annotations; }); } }
ContainerObjectUtil { public static <T extends Annotation> List<T> getAllAnnotations(final Class<?> source, final Class<T> annotationClass) { return AccessController.doPrivileged((PrivilegedAction<List<T>>) () -> { List<T> annotations = new ArrayList<>(); Class<?> nextSource = source; while (nextSource != Object.class) { final T[] annotationsByType = nextSource.getAnnotationsByType(annotationClass); Collections.addAll(annotations, annotationsByType); nextSource = nextSource.getSuperclass(); } return annotations; }); } private  ContainerObjectUtil(); }
ContainerObjectUtil { public static <T extends Annotation> List<T> getAllAnnotations(final Class<?> source, final Class<T> annotationClass) { return AccessController.doPrivileged((PrivilegedAction<List<T>>) () -> { List<T> annotations = new ArrayList<>(); Class<?> nextSource = source; while (nextSource != Object.class) { final T[] annotationsByType = nextSource.getAnnotationsByType(annotationClass); Collections.addAll(annotations, annotationsByType); nextSource = nextSource.getSuperclass(); } return annotations; }); } private  ContainerObjectUtil(); static List<T> getAllAnnotations(final Class<?> source,
        final Class<T> annotationClass); static T getTopCubeAttribute(final Class<?> source, final String nameField,
        final Class<? extends Annotation> annotationClass, final T defaultValue); }
ContainerObjectUtil { public static <T extends Annotation> List<T> getAllAnnotations(final Class<?> source, final Class<T> annotationClass) { return AccessController.doPrivileged((PrivilegedAction<List<T>>) () -> { List<T> annotations = new ArrayList<>(); Class<?> nextSource = source; while (nextSource != Object.class) { final T[] annotationsByType = nextSource.getAnnotationsByType(annotationClass); Collections.addAll(annotations, annotationsByType); nextSource = nextSource.getSuperclass(); } return annotations; }); } private  ContainerObjectUtil(); static List<T> getAllAnnotations(final Class<?> source,
        final Class<T> annotationClass); static T getTopCubeAttribute(final Class<?> source, final String nameField,
        final Class<? extends Annotation> annotationClass, final T defaultValue);  }