List of usage examples for org.springframework.util ReflectionUtils getUniqueDeclaredMethods
public static Method[] getUniqueDeclaredMethods(Class<?> leafClass)
From source file:com.linecorp.bot.spring.boot.support.LineMessageHandlerSupport.java
@VisibleForTesting void refresh() {//from w w w . j a va2 s . c o m final Map<String, Object> handlerBeanMap = applicationContext .getBeansWithAnnotation(LineMessageHandler.class); final List<HandlerMethod> collect = handlerBeanMap.values().stream().flatMap((Object bean) -> { final Method[] uniqueDeclaredMethods = ReflectionUtils.getUniqueDeclaredMethods(bean.getClass()); return Arrays.stream(uniqueDeclaredMethods).map(method -> getMethodHandlerMethodFunction(bean, method)) .filter(Objects::nonNull); }).sorted(HANDLER_METHOD_PRIORITY_COMPARATOR).collect(Collectors.toList()); log.info("Registered LINE Messaging API event handler: count = {}", collect.size()); collect.forEach(item -> log.info("Mapped \"{}\" onto {}", item.getSupportType(), item.getHandler().toGenericString())); eventConsumerList = collect; }
From source file:com.haulmont.cuba.gui.ControllerDependencyInjector.java
protected static List<Method> getAnnotatedListenerMethodsNotCached(Class<?> clazz) { Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); List<Method> eventListenerMethods = Arrays.stream(methods) .filter(m -> m.getAnnotation(EventListener.class) != null).collect(Collectors.toList()); if (eventListenerMethods.isEmpty()) { return Collections.emptyList(); }/*from w w w. ja v a2 s .co m*/ return ImmutableList.copyOf(eventListenerMethods); }
From source file:org.springframework.test.context.transaction.TransactionalTestExecutionListener.java
/** * Get all methods in the supplied {@link Class class} and its superclasses * which are annotated with the supplied {@code annotationType} but * which are not <em>shadowed</em> by methods overridden in subclasses. * <p>Default methods on interfaces are also detected. * @param clazz the class for which to retrieve the annotated methods * @param annotationType the annotation type for which to search * @return all annotated methods in the supplied class and its superclasses * as well as annotated interface default methods */// w ww . j av a 2 s. co m private List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationType) { return Arrays.stream(ReflectionUtils.getUniqueDeclaredMethods(clazz)) .filter(method -> AnnotatedElementUtils.hasAnnotation(method, annotationType)) .collect(Collectors.toList()); }