org.springframework.core.MethodParameter

Here are the examples of the java api org.springframework.core.MethodParameter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2398 Examples 7

19 View Source File : ContextArgumentResolver.java
License : Apache License 2.0
Project Creator : zuihou

/**
 * 入参筛选
 *
 * @param mp 参数集合
 * @return 格式化后的参数
 */
@Override
public boolean supportsParameter(MethodParameter mp) {
    return mp.hasParameterAnnotation(LoginUser.clreplaced) && mp.getParameterType().equals(SysUser.clreplaced);
}

19 View Source File : AbstractGlobalResponseBodyAdvice.java
License : Apache License 2.0
Project Creator : zuihou

@Override
public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Clreplaced aClreplaced, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
    if (o == null) {
        return null;
    }
    if (o instanceof R) {
        return o;
    }
    return R.success(o);
}

19 View Source File : TokenArgumentResolver.java
License : Apache License 2.0
Project Creator : zlt2000

/**
 * 入参筛选
 *
 * @param methodParameter 参数集合
 * @return 格式化后的参数
 */
@Override
public boolean supportsParameter(MethodParameter methodParameter) {
    return methodParameter.hasParameterAnnotation(LoginUser.clreplaced) && methodParameter.getParameterType().equals(SysUser.clreplaced);
}

19 View Source File : ClientArgumentResolver.java
License : Apache License 2.0
Project Creator : zlt2000

/**
 * 入参筛选
 *
 * @param methodParameter 参数集合
 * @return 格式化后的参数
 */
@Override
public boolean supportsParameter(MethodParameter methodParameter) {
    return methodParameter.hasParameterAnnotation(LoginClient.clreplaced) && methodParameter.getParameterType().equals(String.clreplaced);
}

19 View Source File : GlobalResultHandler.java
License : MIT License
Project Creator : zidoshare

@Override
public boolean supports(MethodParameter returnType, Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    // 支持Optional包装
    return !factory.isExceptedClreplaced(returnType.nestedIfOptional().getParameterType());
}

19 View Source File : SortArgumentResolver.java
License : Apache License 2.0
Project Creator : zhouxx

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return Sort.clreplaced.equals(parameter.getParameterType());
}

19 View Source File : PageableArgumentResolver.java
License : Apache License 2.0
Project Creator : zhouxx

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return Pageable.clreplaced.equals(parameter.getParameterType()) || Page.clreplaced.equals(parameter.getParameterType());
}

/**
 * 判断返回类型是否需要转成字符串返回
 * @param returnType 方法返回类型
 * @return 需要转换返回true,否则返回false
 */
@Override
public boolean supportsReturnType(MethodParameter returnType) {
    return delegate.supportsReturnType(returnType);
}

19 View Source File : TokenToUserMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : ZHENFENG13

public boolean supportsParameter(MethodParameter parameter) {
    if (parameter.hasParameterAnnotation(TokenToUser.clreplaced)) {
        return true;
    }
    return false;
}

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().isreplacedignableFrom(UserEnreplacedy.clreplaced) && parameter.hasParameterAnnotation(LoginUser.clreplaced);
}

19 View Source File : LoginUserHandlerMethodArgumentResolver.java
License : GNU General Public License v3.0
Project Creator : zcbin

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().isreplacedignableFrom(Integer.clreplaced) && parameter.hasParameterAnnotation(LoginUser.clreplaced);
}

19 View Source File : ControllerAdviceHandler.java
License : Apache License 2.0
Project Creator : yz-java

@Override
public boolean supports(MethodParameter returnType, Clreplaced converterType) {
    return true;
}

19 View Source File : ByteDanceOpenDemoResponseAdvice.java
License : MIT License
Project Creator : yydzxz

@Override
public boolean supports(MethodParameter methodParameter, Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    return true;
}

19 View Source File : ByteDanceOpenDemoResponseAdvice.java
License : MIT License
Project Creator : yydzxz

@Override
public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType, Clreplaced<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
    if (body instanceof ByteDanceOpenDemoResponse) {
        return body;
    } else if (body instanceof String) {
        return body;
    } else if (body instanceof byte[]) {
        return body;
    }
    ByteDanceOpenDemoResponse response = new ByteDanceOpenDemoResponse();
    response.setCode(0);
    response.setData(body);
    response.setMsg("success");
    return response;
}

19 View Source File : GlobalResponseBodyHandler.java
License : MIT License
Project Creator : YunaiV

@Override
// 避免 IDEA 警告
@SuppressWarnings("NullableProblems")
public boolean supports(MethodParameter returnType, Clreplaced converterType) {
    if (returnType.getMethod() == null) {
        return false;
    }
    // 只拦截返回结果为 CommonResult 类型
    return returnType.getMethod().getReturnType() == CommonResult.clreplaced;
}

19 View Source File : PageableMethodArgumentResolver.java
License : MIT License
Project Creator : ymm-tech

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType() == Pageable.clreplaced;
}

19 View Source File : ResultResponseBodyHandler.java
License : Apache License 2.0
Project Creator : yl-yue

@Override
public boolean supports(MethodParameter returnType, Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    if (returnType.getMethod().getReturnType() != Result.clreplaced) {
        return false;
    }
    return true;
}

19 View Source File : JSONObjectArgumentResolver.java
License : Apache License 2.0
Project Creator : yl-yue

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().equals(JSONObject.clreplaced);
}

19 View Source File : LoginUserHandlerMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : yjjdick

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().isreplacedignableFrom(User.clreplaced) && parameter.hasParameterAnnotation(LoginUser.clreplaced);
}

19 View Source File : CometResponseBodyAdvice.java
License : MIT License
Project Creator : yizzuide

@Override
public boolean supports(@NonNull MethodParameter returnType, @NonNull Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    return true;
}

19 View Source File : CometResponseBodyAdvice.java
License : MIT License
Project Creator : yizzuide

@Override
public Object beforeBodyWrite(Object body, @NonNull MethodParameter returnType, @NonNull MediaType selectedContentType, @NonNull Clreplaced<? extends HttpMessageConverter<?>> selectedConverterType, @NonNull ServerHttpRequest request, @NonNull ServerHttpResponse response) {
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes instanceof ServletRequestAttributes) {
        ((ServletRequestAttributes) requestAttributes).getRequest().setAttribute(REQUEST_ATTRIBUTE_BODY, body);
    }
    return body;
}

19 View Source File : CometParamResolver.java
License : MIT License
Project Creator : yizzuide

@Override
public boolean supportsParameter(MethodParameter methodParameter) {
    return methodParameter.hasParameterAnnotation(CometParam.clreplaced);
}

19 View Source File : DefaultHandlerMethodReturnValueHandler.java
License : Apache License 2.0
Project Creator : yin5980280

/**
 * 判断是否标注ignored
 * @param returnType
 * @return
 */
private boolean ignored(MethodParameter returnType) {
    boolean typeIgnored = returnType.getMethod() != null && returnType.getMethod().getDeclaringClreplaced().isAnnotationPresent(Ignored.clreplaced);
    return typeIgnored || returnType.getMethodAnnotation(Ignored.clreplaced) != null;
}

19 View Source File : ThrowableMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getMethod().isAnnotationPresent(OnError.clreplaced) && Throwable.clreplaced.isreplacedignableFrom(parameter.getParameterType());
}

19 View Source File : TextMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getMethod().isAnnotationPresent(OnMessage.clreplaced) && String.clreplaced.isreplacedignableFrom(parameter.getParameterType());
}

19 View Source File : SessionMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return Session.clreplaced.isreplacedignableFrom(parameter.getParameterType());
}

19 View Source File : RequestParamMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(RequestParam.clreplaced);
}

19 View Source File : PathVariableMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(PathVariable.clreplaced);
}

19 View Source File : HttpHeadersMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return HttpHeaders.clreplaced.isreplacedignableFrom(parameter.getParameterType());
}

19 View Source File : ByteMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getMethod().isAnnotationPresent(OnBinary.clreplaced) && byte[].clreplaced.isreplacedignableFrom(parameter.getParameterType());
}

19 View Source File : CurrentAccountMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : xuexiangjys

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return // 判断是否能转成Account类型
    parameter.getParameterType().isreplacedignableFrom(Account.clreplaced) && // 是否有CurrentAccount注解
    parameter.hasParameterAnnotation(CurrentAccount.clreplaced);
}

19 View Source File : AppControllerAdvice.java
License : Apache License 2.0
Project Creator : Xlinlin

@Override
public boolean supports(MethodParameter methodParameter, Clreplaced aClreplaced) {
    return true;
}

19 View Source File : SecureUserArgumentResolver.java
License : GNU Lesser General Public License v3.0
Project Creator : xkcoding

/**
 * 参数上必须包含 {@link CurrentUser} 注解,同时满足参数类型是 {@link SecureUser}
 *
 * @param parameter 参数
 * @return 满足条件 true,反之 false
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().isreplacedignableFrom(SecureUser.clreplaced) && parameter.hasParameterAnnotation(CurrentUser.clreplaced);
}

19 View Source File : GlobalResponseHandler.java
License : Apache License 2.0
Project Creator : Xiao-Y

@Override
public boolean supports(MethodParameter returnType, Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    // 判断支持的类型,因为我们定义的BaseResponseVo 里面的data可能是任何类型,这里就不判断统一放过
    // 如果你想对执行的返回体进行操作,可将上方的Object换成你自己的类型
    return true;
}

19 View Source File : RangeMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : xiangxik

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(RangeParam.clreplaced);
}

19 View Source File : FilterPredicateArgumentResolver.java
License : Apache License 2.0
Project Creator : xiangxik

@Override
public boolean supportsParameter(MethodParameter parameter) {
    if (Predicate.clreplaced.equals(parameter.getParameterType())) {
        return true;
    }
    if (parameter.hasParameterAnnotation(QuerydslPredicate.clreplaced)) {
        throw new IllegalArgumentException(String.format("Parameter at position %s must be of type Predicate but was %s.", parameter.getParameterIndex(), parameter.getParameterType()));
    }
    return false;
}

19 View Source File : LoginUserArgumentResolver.java
License : MIT License
Project Creator : woowacourse-teams

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(LoginUser.clreplaced);
}

19 View Source File : LoginMemberArgumentResolver.java
License : MIT License
Project Creator : woowacourse-teams

@Override
public boolean supportsParameter(final MethodParameter parameter) {
    return parameter.hasParameterAnnotation(LoginMember.clreplaced);
}

19 View Source File : WeCubeResponseResultProcess.java
License : Apache License 2.0
Project Creator : WeBankPartners

@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Clreplaced<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
    return body;
}

19 View Source File : WeCubeResponseResultProcess.java
License : Apache License 2.0
Project Creator : WeBankPartners

@Override
public boolean supports(MethodParameter returnType, Clreplaced<? extends HttpMessageConverter<?>> converterType) {
    return true;
}

19 View Source File : JwtTokenArgumentResolver.java
License : MIT License
Project Creator : watchdog-framework

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(JwtClaim.clreplaced);
}

19 View Source File : MessageBrokerBeanDefinitionParserTests.java
License : MIT License
Project Creator : Vip-Augus

@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception {
}

19 View Source File : MessageBrokerBeanDefinitionParserTests.java
License : MIT License
Project Creator : Vip-Augus

@Override
public boolean supportsReturnType(MethodParameter returnType) {
    return false;
}

19 View Source File : MessageBrokerBeanDefinitionParserTests.java
License : MIT License
Project Creator : Vip-Augus

@Override
public boolean supportsParameter(MethodParameter parameter) {
    return false;
}

19 View Source File : MessageBrokerBeanDefinitionParserTests.java
License : MIT License
Project Creator : Vip-Augus

@Override
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
    return null;
}

19 View Source File : ServletResponseMethodArgumentResolverTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-8983
@Test
public void servletResponseNoMavContainer() throws Exception {
    MethodParameter servletResponseParameter = new MethodParameter(method, 0);
    replacedertTrue("ServletResponse not supported", resolver.supportsParameter(servletResponseParameter));
    Object result = resolver.resolveArgument(servletResponseParameter, null, webRequest, null);
    replacedertSame("Invalid result", servletResponse, result);
}

19 View Source File : ServletRequestMethodArgumentResolverTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void httpMethod() throws Exception {
    MethodParameter httpMethodParameter = new MethodParameter(method, 10);
    replacedertTrue("HttpMethod not supported", resolver.supportsParameter(httpMethodParameter));
    Object result = resolver.resolveArgument(httpMethodParameter, null, webRequest, null);
    replacedertSame("Invalid result", HttpMethod.valueOf(webRequest.getRequest().getMethod()), result);
}

19 View Source File : ServletRequestMethodArgumentResolverTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void inputStream() throws Exception {
    MethodParameter inputStreamParameter = new MethodParameter(method, 5);
    replacedertTrue("InputStream not supported", resolver.supportsParameter(inputStreamParameter));
    Object result = resolver.resolveArgument(inputStreamParameter, null, webRequest, null);
    replacedertSame("Invalid result", webRequest.getRequest().getInputStream(), result);
}

19 View Source File : ServletRequestMethodArgumentResolverTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void reader() throws Exception {
    MethodParameter readerParameter = new MethodParameter(method, 6);
    replacedertTrue("Reader not supported", resolver.supportsParameter(readerParameter));
    Object result = resolver.resolveArgument(readerParameter, null, webRequest, null);
    replacedertSame("Invalid result", webRequest.getRequest().getReader(), result);
}

19 View Source File : ServletRequestMethodArgumentResolverTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void zoneId() throws Exception {
    MethodParameter zoneIdParameter = new MethodParameter(method, 9);
    replacedertTrue("ZoneId not supported", resolver.supportsParameter(zoneIdParameter));
    Object result = resolver.resolveArgument(zoneIdParameter, null, webRequest, null);
    replacedertEquals("Invalid result", ZoneId.systemDefault(), result);
}

See More Examples