@Test public void breakDownIfRepeatable() throws Exception { Method method = TestHandler.getTestMethod(); Collection<Annotation> actual = CEKRequestMappingHandlerMapping.breakDownIfRepeatable( method.getAnnotation(DummyConditions.class)); List<Annotation> expected = Arrays.asList(method.getAnnotationsByType(DummyCondition.class)); assertThat(actual).isEqualTo(expected); }
static Collection<Annotation> breakDownIfRepeatable(Annotation annotation) { Object value = AnnotationUtils.getValue(annotation); if (value == null) { return Collections.singleton(annotation); } if (!value.getClass().isArray()) { return Collections.singleton(annotation); } Object[] annotations = (Object[]) value; if (annotations.length == 0) { return Collections.singleton(annotation); } if (!Arrays.stream(annotations) .findFirst() .filter(Annotation.class::isInstance) .map(Annotation.class::cast) .map(repeating -> repeating.annotationType().getAnnotation(Repeatable.class)) .filter(repeatable -> repeatable.value().isInstance(annotation)) .isPresent()) { return Collections.singleton(annotation); } return Arrays.asList((Annotation[]) annotations); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { static Collection<Annotation> breakDownIfRepeatable(Annotation annotation) { Object value = AnnotationUtils.getValue(annotation); if (value == null) { return Collections.singleton(annotation); } if (!value.getClass().isArray()) { return Collections.singleton(annotation); } Object[] annotations = (Object[]) value; if (annotations.length == 0) { return Collections.singleton(annotation); } if (!Arrays.stream(annotations) .findFirst() .filter(Annotation.class::isInstance) .map(Annotation.class::cast) .map(repeating -> repeating.annotationType().getAnnotation(Repeatable.class)) .filter(repeatable -> repeatable.value().isInstance(annotation)) .isPresent()) { return Collections.singleton(annotation); } return Arrays.asList((Annotation[]) annotations); } }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { static Collection<Annotation> breakDownIfRepeatable(Annotation annotation) { Object value = AnnotationUtils.getValue(annotation); if (value == null) { return Collections.singleton(annotation); } if (!value.getClass().isArray()) { return Collections.singleton(annotation); } Object[] annotations = (Object[]) value; if (annotations.length == 0) { return Collections.singleton(annotation); } if (!Arrays.stream(annotations) .findFirst() .filter(Annotation.class::isInstance) .map(Annotation.class::cast) .map(repeating -> repeating.annotationType().getAnnotation(Repeatable.class)) .filter(repeatable -> repeatable.value().isInstance(annotation)) .isPresent()) { return Collections.singleton(annotation); } return Arrays.asList((Annotation[]) annotations); }  }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { static Collection<Annotation> breakDownIfRepeatable(Annotation annotation) { Object value = AnnotationUtils.getValue(annotation); if (value == null) { return Collections.singleton(annotation); } if (!value.getClass().isArray()) { return Collections.singleton(annotation); } Object[] annotations = (Object[]) value; if (annotations.length == 0) { return Collections.singleton(annotation); } if (!Arrays.stream(annotations) .findFirst() .filter(Annotation.class::isInstance) .map(Annotation.class::cast) .map(repeating -> repeating.annotationType().getAnnotation(Repeatable.class)) .filter(repeatable -> repeatable.value().isInstance(annotation)) .isPresent()) { return Collections.singleton(annotation); } return Arrays.asList((Annotation[]) annotations); }  @Override void afterPropertiesSet(); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { static Collection<Annotation> breakDownIfRepeatable(Annotation annotation) { Object value = AnnotationUtils.getValue(annotation); if (value == null) { return Collections.singleton(annotation); } if (!value.getClass().isArray()) { return Collections.singleton(annotation); } Object[] annotations = (Object[]) value; if (annotations.length == 0) { return Collections.singleton(annotation); } if (!Arrays.stream(annotations) .findFirst() .filter(Annotation.class::isInstance) .map(Annotation.class::cast) .map(repeating -> repeating.annotationType().getAnnotation(Repeatable.class)) .filter(repeatable -> repeatable.value().isInstance(annotation)) .isPresent()) { return Collections.singleton(annotation); } return Arrays.asList((Annotation[]) annotations); }  @Override void afterPropertiesSet();  }