List of usage examples for org.springframework.core MethodParameter getMethod
@Nullable
public Method getMethod()
From source file:springfox.documentation.swagger.readers.parameter.ParameterAnnotationReader.java
private static Class<?>[] getParentInterfaces(MethodParameter methodParameter) { return methodParameter.getMethod().getDeclaringClass().getInterfaces(); }
From source file:springfox.documentation.swagger.readers.parameter.ParameterAnnotationReader.java
public static <A extends Annotation> Optional<A> fromHierarchy(MethodParameter methodParameter, Class<A> annotationType) { return fromNullable(searchOnInterfaces(methodParameter.getMethod(), methodParameter.getParameterIndex(), annotationType, getParentInterfaces(methodParameter))); }
From source file:com.github.zhanhb.download.spring.PathDownloaderHandler.java
@Override public boolean supportsReturnType(MethodParameter returnType) { return returnType.getMethodAnnotation(ToDownload.class) != null && Path.class.isAssignableFrom(returnType.getMethod().getReturnType()); }
From source file:ch.rasc.wampspring.method.PayloadArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter parameter) { return parameter.getMethod().getAnnotation(WampPublishListener.class) != null; }
From source file:org.focusns.common.web.widget.mvc.method.WidgetMethodArgumentResolver.java
private Object getWidgetAttributeValue(MethodParameter parameter, NativeWebRequest webRequest) { Class<?> widgetClass = parameter.getMethod().getDeclaringClass(); WidgetAttribute widgetAttribute = parameter.getParameterAnnotation(WidgetAttribute.class); if (widgetAttribute != null) { String widgetAttributeName = getWidgetAttributeName(parameter, widgetAttribute); Object value = webRequest.getAttribute(widgetAttributeName, WebRequest.SCOPE_REQUEST); if (widgetAttribute.required()) { Assert.notNull(value,/*from ww w . j av a 2 s. c om*/ String.format("%s attribute %s can not be null!", widgetClass, widgetAttributeName)); } return value; } // return null; }
From source file:springfox.documentation.spring.web.readers.parameter.ParameterNameReader.java
private Optional<String> discoveredName(MethodParameter methodParameter) { String[] discoveredNames = parameterNameDiscover.getParameterNames(methodParameter.getMethod()); return discoveredNames != null && methodParameter.getParameterIndex() < discoveredNames.length ? Optional.fromNullable(emptyToNull(discoveredNames[methodParameter.getParameterIndex()])) : Optional.<String>absent(); }
From source file:com.netflix.genie.web.controllers.GenieExceptionMapperUnitTests.java
/** * Test method argument not valid exceptions. * * @throws IOException on error// ww w . j a v a2 s. c om */ @Test @SuppressFBWarnings(value = "DM_NEW_FOR_GETCLASS", justification = "It's needed for the test") public void canHandleMethodArgumentNotValidExceptions() throws IOException { // Method is a final class so can't mock it. Just use the current method. final Method method = new Object() { }.getClass().getEnclosingMethod(); final MethodParameter parameter = Mockito.mock(MethodParameter.class); Mockito.when(parameter.getMethod()).thenReturn(method); final BindingResult bindingResult = Mockito.mock(BindingResult.class); Mockito.when(bindingResult.getAllErrors()).thenReturn(Lists.newArrayList()); final MethodArgumentNotValidException exception = new MethodArgumentNotValidException(parameter, bindingResult); this.mapper.handleMethodArgumentNotValidException(this.response, exception); Mockito.verify(this.response, Mockito.times(1)) .sendError(Mockito.eq(HttpStatus.PRECONDITION_FAILED.value()), Mockito.anyString()); Mockito.verify(counterId, Mockito.times(1)).withTag(MetricsConstants.TagKeys.EXCEPTION_CLASS, exception.getClass().getCanonicalName()); Mockito.verify(counter, Mockito.times(1)).increment(); }
From source file:com.payu.ratel.client.ContextAnnotationAutowireCandidateResolver.java
protected boolean isLazy(DependencyDescriptor descriptor) { for (Annotation ann : descriptor.getAnnotations()) { Lazy lazy = AnnotationUtils.getAnnotation(ann, Lazy.class); if (lazy != null && lazy.value()) { return true; }/* w ww . j a v a2s.c o m*/ } MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam == null) { return false; } Method method = methodParam.getMethod(); if (method == null || void.class.equals(method.getReturnType())) { Lazy lazy = AnnotationUtils.getAnnotation(methodParam.getAnnotatedElement(), Lazy.class); if (lazy != null && lazy.value()) { return true; } } return false; }
From source file:fr.mby.utils.spring.beans.factory.ProxywiredMethodParam.java
protected ProxywiredMethodParam(final DependencyDescriptor descriptor, final String wiredClassName) { super();/*from ww w . j a v a 2 s. co m*/ Assert.notNull(descriptor, "No DependencyDescriptor provided !"); final MethodParameter methodParam = descriptor.getMethodParameter(); Assert.notNull(methodParam, "DependencyDescriptor provided don't describe a Method parameter !"); final String methodName = methodParam.getMethod().getName(); final String paramName = methodParam.getParameterName(); Assert.hasText(wiredClassName, "Wired class name cannot be found !"); this.buildNodePath(wiredClassName, methodName, paramName); }
From source file:cn.guoyukun.spring.jpa.web.bind.method.annotation.PageableMethodArgumentResolver.java
/** * Asserts uniqueness of all {@link Pageable} parameters of the method of the given {@link MethodParameter}. * * @param parameter//from w w w. j a v a 2s . c o m */ private void assertPageableUniqueness(MethodParameter parameter) { Method method = parameter.getMethod(); if (containsMoreThanOnePageableParameter(method)) { Annotation[][] annotations = method.getParameterAnnotations(); assertQualifiersFor(method.getParameterTypes(), annotations); } }