@Test public void extractConditionMatcherFactories_BeanType() throws Exception { Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> conditionMatcherFactories = CEKRequestMappingHandlerMapping.extractConditionMatcherFactories(TestHandler.class); assertThat(conditionMatcherFactories) .containsOnlyKeys(ExtensionIdConditionMatcherFactory.class); assertThat(conditionMatcherFactories.get(ExtensionIdConditionMatcherFactory.class)) .containsOnlyOnce(AnnotationUtils.getAnnotation(TestHandler.class, ExtensionIdCondition.class)) .hasSize(1); }
@SuppressWarnings("rawTypes") static Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> extractConditionMatcherFactories(Object beanTypeOrMethod) { Assert.isTrue(beanTypeOrMethod instanceof Class || beanTypeOrMethod instanceof Method, "beanTypeOrMethod should be Class or Method. " + "[beanTypeOrMethod:" + beanTypeOrMethod + "]"); Annotation[] annotations = AnnotationUtils.getAnnotations((AnnotatedElement) beanTypeOrMethod); if (annotations == null || annotations.length == 0) { return Collections.emptyMap(); } return Arrays.stream(annotations) .flatMap(annotation -> searchCEKHandleCondition(annotation).stream()) .collect(groupingBy(annotation -> annotation.annotationType() .getAnnotation(CEKHandleCondition.class) .value(), mapping(Function.identity(), Collectors.toSet()))); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { @SuppressWarnings("rawTypes") static Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> extractConditionMatcherFactories(Object beanTypeOrMethod) { Assert.isTrue(beanTypeOrMethod instanceof Class || beanTypeOrMethod instanceof Method, "beanTypeOrMethod should be Class or Method. " + "[beanTypeOrMethod:" + beanTypeOrMethod + "]"); Annotation[] annotations = AnnotationUtils.getAnnotations((AnnotatedElement) beanTypeOrMethod); if (annotations == null || annotations.length == 0) { return Collections.emptyMap(); } return Arrays.stream(annotations) .flatMap(annotation -> searchCEKHandleCondition(annotation).stream()) .collect(groupingBy(annotation -> annotation.annotationType() .getAnnotation(CEKHandleCondition.class) .value(), mapping(Function.identity(), Collectors.toSet()))); } }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { @SuppressWarnings("rawTypes") static Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> extractConditionMatcherFactories(Object beanTypeOrMethod) { Assert.isTrue(beanTypeOrMethod instanceof Class || beanTypeOrMethod instanceof Method, "beanTypeOrMethod should be Class or Method. " + "[beanTypeOrMethod:" + beanTypeOrMethod + "]"); Annotation[] annotations = AnnotationUtils.getAnnotations((AnnotatedElement) beanTypeOrMethod); if (annotations == null || annotations.length == 0) { return Collections.emptyMap(); } return Arrays.stream(annotations) .flatMap(annotation -> searchCEKHandleCondition(annotation).stream()) .collect(groupingBy(annotation -> annotation.annotationType() .getAnnotation(CEKHandleCondition.class) .value(), mapping(Function.identity(), Collectors.toSet()))); }  }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { @SuppressWarnings("rawTypes") static Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> extractConditionMatcherFactories(Object beanTypeOrMethod) { Assert.isTrue(beanTypeOrMethod instanceof Class || beanTypeOrMethod instanceof Method, "beanTypeOrMethod should be Class or Method. " + "[beanTypeOrMethod:" + beanTypeOrMethod + "]"); Annotation[] annotations = AnnotationUtils.getAnnotations((AnnotatedElement) beanTypeOrMethod); if (annotations == null || annotations.length == 0) { return Collections.emptyMap(); } return Arrays.stream(annotations) .flatMap(annotation -> searchCEKHandleCondition(annotation).stream()) .collect(groupingBy(annotation -> annotation.annotationType() .getAnnotation(CEKHandleCondition.class) .value(), mapping(Function.identity(), Collectors.toSet()))); }  @Override void afterPropertiesSet(); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { @SuppressWarnings("rawTypes") static Map<Class<? extends CEKHandleConditionMatcherFactory>, Set<Annotation>> extractConditionMatcherFactories(Object beanTypeOrMethod) { Assert.isTrue(beanTypeOrMethod instanceof Class || beanTypeOrMethod instanceof Method, "beanTypeOrMethod should be Class or Method. " + "[beanTypeOrMethod:" + beanTypeOrMethod + "]"); Annotation[] annotations = AnnotationUtils.getAnnotations((AnnotatedElement) beanTypeOrMethod); if (annotations == null || annotations.length == 0) { return Collections.emptyMap(); } return Arrays.stream(annotations) .flatMap(annotation -> searchCEKHandleCondition(annotation).stream()) .collect(groupingBy(annotation -> annotation.annotationType() .getAnnotation(CEKHandleCondition.class) .value(), mapping(Function.identity(), Collectors.toSet()))); }  @Override void afterPropertiesSet();  }