Here are the examples of the java api org.springframework.core.MethodParameter.getParameterAnnotation() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
128 Examples
19
View Source File : PathVariableMapMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE
License : Apache License 2.0
Project Creator : YeautyYE
@Override
public boolean supportsParameter(MethodParameter parameter) {
PathVariable ann = parameter.getParameterAnnotation(PathVariable.clreplaced);
return (ann != null && Map.clreplaced.isreplacedignableFrom(parameter.getParameterType()) && !StringUtils.hasText(ann.value()));
}
19
View Source File : FilterPredicateArgumentResolver.java
License : Apache License 2.0
Project Creator : xiangxik
License : Apache License 2.0
Project Creator : xiangxik
static TypeInformation<?> extractTypeInfo(MethodParameter parameter) {
QuerydslPredicate annotation = parameter.getParameterAnnotation(QuerydslPredicate.clreplaced);
if (annotation != null && !Object.clreplaced.equals(annotation.root())) {
return ClreplacedTypeInformation.from(annotation.root());
}
return detectDomainType(ClreplacedTypeInformation.fromReturnTypeOf(parameter.getMethod()));
}
19
View Source File : SessionAttributeMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
SessionAttribute ann = parameter.getParameterAnnotation(SessionAttribute.clreplaced);
replacedert.state(ann != null, "No SessionAttribute annotation");
return new NamedValueInfo(ann.name(), ann.required(), ValueConstants.DEFAULT_NONE);
}
19
View Source File : MatrixVariableMapMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public boolean supportsParameter(MethodParameter parameter) {
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
return (matrixVariable != null && Map.clreplaced.isreplacedignableFrom(parameter.getParameterType()) && !StringUtils.hasText(matrixVariable.name()));
}
19
View Source File : RequestHeaderMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestHeader ann = parameter.getParameterAnnotation(RequestHeader.clreplaced);
replacedert.state(ann != null, "No RequestHeader annotation");
return new RequestHeaderNamedValueInfo(ann);
}
19
View Source File : ModelInitializer.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Derive the model attribute name for the given method parameter based on
* a {@code @ModelAttribute} parameter annotation (if present) or falling
* back on parameter type based conventions.
* @param parameter a descriptor for the method parameter
* @return the derived name
* @see Conventions#getVariableNameForParameter(MethodParameter)
*/
public static String getNameForParameter(MethodParameter parameter) {
ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.clreplaced);
String name = (ann != null ? ann.value() : null);
return (StringUtils.hasText(name) ? name : Conventions.getVariableNameForParameter(parameter));
}
19
View Source File : CookieValueMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
CookieValue ann = parameter.getParameterAnnotation(CookieValue.clreplaced);
replacedert.state(ann != null, "No CookieValue annotation");
return new CookieValueNamedValueInfo(ann);
}
19
View Source File : AbstractCookieValueMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
CookieValue annotation = parameter.getParameterAnnotation(CookieValue.clreplaced);
replacedert.state(annotation != null, "No CookieValue annotation");
return new CookieValueNamedValueInfo(annotation);
}
19
View Source File : AbstractJackson2Decoder.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// Jackson2CodecSupport ...
@Override
protected <A extends Annotation> A getAnnotation(MethodParameter parameter, Clreplaced<A> annotType) {
return parameter.getParameterAnnotation(annotType);
}
19
View Source File : DestinationVariableMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
DestinationVariable annot = parameter.getParameterAnnotation(DestinationVariable.clreplaced);
replacedert.state(annot != null, "No DestinationVariable annotation");
return new DestinationVariableNamedValueInfo(annot);
}
19
View Source File : ParameterCustomizer.java
License : Apache License 2.0
Project Creator : springdoc
License : Apache License 2.0
Project Creator : springdoc
@Override
public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) {
CustomizedParameter annotation = methodParameter.getParameterAnnotation(CustomizedParameter.clreplaced);
if (annotation != null) {
parameterModel.description(parameterModel.getDescription() + ", " + annotation.addition());
}
return parameterModel;
}
19
View Source File : DataRestRequestService.java
License : Apache License 2.0
Project Creator : springdoc
License : Apache License 2.0
Project Creator : springdoc
/**
* Is header to ignore boolean.
*
* @param methodParameter the method parameter
* @return the boolean
*/
private boolean isHeaderToIgnore(MethodParameter methodParameter) {
RequestHeader requestHeader = methodParameter.getParameterAnnotation(RequestHeader.clreplaced);
return requestHeader != null && HttpHeaders.ACCEPT.equals(requestHeader.value());
}
19
View Source File : SortHandlerMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : open-hand
License : Apache License 2.0
Project Creator : open-hand
protected String getSortParameter(MethodParameter parameter) {
StringBuilder builder = new StringBuilder();
if (parameter != null && parameter.hasParameterAnnotation(Qualifier.clreplaced)) {
builder.append(parameter.getParameterAnnotation(Qualifier.clreplaced).value()).append(qualifierDelimiter);
}
return builder.append(sortParameter).toString();
}
19
View Source File : PageRequestHandlerMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : open-hand
License : Apache License 2.0
Project Creator : open-hand
protected String getParameterNameToUse(String source, MethodParameter parameter) {
StringBuilder builder = new StringBuilder(prefix);
if (parameter != null && parameter.hasParameterAnnotation(Qualifier.clreplaced)) {
builder.append(parameter.getParameterAnnotation(Qualifier.clreplaced).value());
builder.append(qualifierDelimiter);
}
return builder.append(source).toString();
}
19
View Source File : BotTextVariableMethodArgumentResolver.java
License : MIT License
Project Creator : OlegNyr
License : MIT License
Project Creator : OlegNyr
private NamedValueInfo getNamedValueInfo(MethodParameter parameter) {
NamedValueInfo namedValueInfo = this.namedValueInfoCache.get(parameter);
if (namedValueInfo == null) {
TextVariable annotation = parameter.getParameterAnnotation(TextVariable.clreplaced);
namedValueInfo = new NamedValueInfo(annotation.name() == null ? parameter.getParameterName() : annotation.name(), annotation.required());
this.namedValueInfoCache.put(parameter, namedValueInfo);
}
return namedValueInfo;
}
19
View Source File : DestinationVariableMethodArgumentResolver.java
License : MIT License
Project Creator : mindcarver
License : MIT License
Project Creator : mindcarver
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
DestinationVariable annotation = parameter.getParameterAnnotation(DestinationVariable.clreplaced);
replacedert.state(annotation != null, "No DestinationVariable annotation");
return new DestinationVariableNamedValueInfo(annotation);
}
19
View Source File : ParamHandler.java
License : GNU General Public License v3.0
Project Creator : liuanxin
License : GNU General Public License v3.0
Project Creator : liuanxin
private static boolean paramHasMust(MethodParameter parameter) {
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.clreplaced);
if (Tools.isNotBlank(requestParam) && requestParam.required()) {
return true;
}
PathVariable pathVariable = parameter.getParameterAnnotation(PathVariable.clreplaced);
if (Tools.isNotBlank(pathVariable) && pathVariable.required()) {
return true;
}
RequestBody requestBody = parameter.getParameterAnnotation(RequestBody.clreplaced);
if (Tools.isNotBlank(requestBody) && requestBody.required()) {
return true;
}
RequestAttribute requestAttribute = parameter.getParameterAnnotation(RequestAttribute.clreplaced);
if (Tools.isNotBlank(requestAttribute) && requestAttribute.required()) {
return true;
}
RequestHeader requestHeader = parameter.getParameterAnnotation(RequestHeader.clreplaced);
if (Tools.isNotBlank(requestHeader) && requestHeader.required()) {
return true;
}
RequestPart requestPart = parameter.getParameterAnnotation(RequestPart.clreplaced);
if (Tools.isNotBlank(requestPart) && requestPart.required()) {
return true;
}
SessionAttribute sessionAttribute = parameter.getParameterAnnotation(SessionAttribute.clreplaced);
if (Tools.isNotBlank(sessionAttribute) && sessionAttribute.required()) {
return true;
}
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
if (Tools.isNotBlank(matrixVariable) && matrixVariable.required()) {
return true;
}
CookieValue cookieValue = parameter.getParameterAnnotation(CookieValue.clreplaced);
return Tools.isNotBlank(cookieValue) && cookieValue.required();
}
19
View Source File : ParamHandler.java
License : GNU General Public License v3.0
Project Creator : liuanxin
License : GNU General Public License v3.0
Project Creator : liuanxin
private static String getParamName(MethodParameter parameter, String paramName) {
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.clreplaced);
if (Tools.isNotBlank(requestParam) && Tools.isNotEmpty(requestParam.value())) {
return requestParam.value();
}
PathVariable pathVariable = parameter.getParameterAnnotation(PathVariable.clreplaced);
if (Tools.isNotBlank(pathVariable) && Tools.isNotEmpty(pathVariable.value())) {
return pathVariable.value();
}
RequestAttribute requestAttribute = parameter.getParameterAnnotation(RequestAttribute.clreplaced);
if (Tools.isNotBlank(requestAttribute) && Tools.isNotEmpty(requestAttribute.value())) {
return requestAttribute.value();
}
RequestHeader requestHeader = parameter.getParameterAnnotation(RequestHeader.clreplaced);
if (Tools.isNotBlank(requestHeader) && Tools.isNotEmpty(requestHeader.value())) {
return requestHeader.value();
}
RequestPart requestPart = parameter.getParameterAnnotation(RequestPart.clreplaced);
if (Tools.isNotBlank(requestPart) && Tools.isNotEmpty(requestPart.value())) {
return requestPart.value();
}
SessionAttribute sessionAttribute = parameter.getParameterAnnotation(SessionAttribute.clreplaced);
if (Tools.isNotBlank(sessionAttribute) && Tools.isNotEmpty(sessionAttribute.value())) {
return sessionAttribute.value();
}
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
if (Tools.isNotBlank(matrixVariable) && Tools.isNotEmpty(matrixVariable.value())) {
return matrixVariable.value();
}
CookieValue cookieValue = parameter.getParameterAnnotation(CookieValue.clreplaced);
if (Tools.isNotBlank(cookieValue) && Tools.isNotEmpty(cookieValue.value())) {
return cookieValue.value();
}
return paramName;
}
19
View Source File : SolrParameter.java
License : Apache License 2.0
Project Creator : learningtcc
License : Apache License 2.0
Project Creator : learningtcc
private Boost getBoostAnnotation() {
return parameter.getParameterAnnotation(Boost.clreplaced);
}
19
View Source File : MatrixVariableMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
return new MatrixVariableNamedValueInfo(annotation);
}
19
View Source File : RequestHeaderMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestHeader annotation = parameter.getParameterAnnotation(RequestHeader.clreplaced);
return new RequestHeaderNamedValueInfo(annotation);
}
19
View Source File : ModelFactory.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
/**
* Derives the model attribute name for a method parameter based on:
* <ol>
* <li>The parameter {@code @ModelAttribute} annotation value
* <li>The parameter type
* </ol>
* @return the derived name; never {@code null} or an empty string
*/
public static String getNameForParameter(MethodParameter parameter) {
ModelAttribute annot = parameter.getParameterAnnotation(ModelAttribute.clreplaced);
String attrName = (annot != null) ? annot.value() : null;
return StringUtils.hasText(attrName) ? attrName : Conventions.getVariableNameForParameter(parameter);
}
19
View Source File : AbstractCookieValueMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
CookieValue annotation = parameter.getParameterAnnotation(CookieValue.clreplaced);
return new CookieValueNamedValueInfo(annotation);
}
19
View Source File : HeaderMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
Header annotation = parameter.getParameterAnnotation(Header.clreplaced);
return new HeaderNamedValueInfo(annotation);
}
19
View Source File : DestinationVariableMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
DestinationVariable annotation = parameter.getParameterAnnotation(DestinationVariable.clreplaced);
return new DestinationVariableNamedValueInfo(annotation);
}
19
View Source File : IdParamMethodArgumentResolver.java
License : GNU General Public License v3.0
Project Creator : getrebuild
License : GNU General Public License v3.0
Project Creator : getrebuild
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
IdParam param = parameter.getParameterAnnotation(IdParam.clreplaced);
replacedert.notNull(param, "[IdParam] cannot be null");
String value = webRequest.getParameter(param.name());
ID idValue = ID.isId(value) ? ID.valueOf(value) : null;
if (param.required() && idValue == null) {
throw new InvalidParameterException(Language.LF("BadRequestParamsSome", param.name(), value));
}
return idValue;
}
19
View Source File : EntityParamMethodArgumentResolver.java
License : GNU General Public License v3.0
Project Creator : getrebuild
License : GNU General Public License v3.0
Project Creator : getrebuild
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
EnreplacedyParam param = parameter.getParameterAnnotation(EnreplacedyParam.clreplaced);
replacedert.notNull(param, "[EnreplacedyParam] cannot be null");
String value = webRequest.getParameter(param.name());
if (StringUtils.isBlank(value)) {
if (param.required()) {
throw new InvalidParameterException(Language.LF("BadRequestParamsSome", param.name(), value));
}
return null;
}
if (MetadataHelper.containsEnreplacedy(value)) {
return MetadataHelper.getEnreplacedy(value);
}
throw new InvalidParameterException(Language.L("BadRequestParams"));
}
19
View Source File : RequestParamFactory.java
License : Apache License 2.0
Project Creator : codex-league
License : Apache License 2.0
Project Creator : codex-league
/**
* 获取 RequestParam 的必填信息
*
* @param methodParameter
* @return
*/
public static Boolean getRequired(MethodParameter methodParameter) {
Annotation requestParamAnnotation = methodParameter.getParameterAnnotation(RequestParam.clreplaced);
if (requestParamAnnotation != null) {
return ((RequestParam) requestParamAnnotation).required();
}
return null;
}
19
View Source File : PathVariableFactory.java
License : Apache License 2.0
Project Creator : codex-league
License : Apache License 2.0
Project Creator : codex-league
/**
* 获取 RequestParam 的必填信息
*
* @param methodParameter
* @return
*/
public static Boolean getRequired(MethodParameter methodParameter) {
Annotation requestParamAnnotation = methodParameter.getParameterAnnotation(PathVariable.clreplaced);
if (requestParamAnnotation != null) {
return ((PathVariable) requestParamAnnotation).required();
}
return null;
}
19
View Source File : ApiParamFactory.java
License : Apache License 2.0
Project Creator : codex-league
License : Apache License 2.0
Project Creator : codex-league
/**
* 获取 ApiParam 的描述信息
*
* @param methodParameter
* @return
*/
public static String getDescribe(MethodParameter methodParameter) {
Annotation apiParamAnnotation = methodParameter.getParameterAnnotation(ApiParam.clreplaced);
if (apiParamAnnotation != null) {
return ((ApiParam) apiParamAnnotation).describe();
}
return null;
}
19
View Source File : ExternalSessionArgumentResolver.java
License : Apache License 2.0
Project Creator : bliblidotcom
License : Apache License 2.0
Project Creator : bliblidotcom
private MustMember getMustMemberAnnotation(MethodParameter parameter) {
MustMember annotation = parameter.getParameterAnnotation(MustMember.clreplaced);
if (annotation == null) {
annotation = parameter.getMethodAnnotation(MustMember.clreplaced);
}
if (annotation == null) {
annotation = parameter.getMember().getDeclaringClreplaced().getAnnotation(MustMember.clreplaced);
}
return annotation;
}
19
View Source File : ResponseStatusWebErrorHandler.java
License : Apache License 2.0
Project Creator : alimate
License : Apache License 2.0
Project Creator : alimate
/**
* Spring WebFlux throw just one exception, i.e. {@link WebExchangeBindException} for
* all request body binding failures, i.e. missing required parameter or missing matrix
* variables. On the contrary, Traditional web stack throw one specific exception for
* each scenario. In order to provide a consistent API for both stacks, we chose to
* throw a bunch of if-else es to determines the actual cause and provide explicit feedback
* to the client.
*
* @param parameter The invalid method parameter.
* @return Possibly a handled exception.
*/
private HandledException handleMissingParameters(MethodParameter parameter) {
if (parameter == null)
return null;
String code = null;
String parameterName = null;
RequestHeader requestHeader = parameter.getParameterAnnotation(RequestHeader.clreplaced);
if (requestHeader != null) {
code = MISSING_HEADER;
parameterName = extractParameterName(requestHeader, parameter);
}
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.clreplaced);
if (requestParam != null) {
code = MISSING_PARAMETER;
parameterName = extractParameterName(requestParam, parameter);
}
RequestPart requestPart = parameter.getParameterAnnotation(RequestPart.clreplaced);
if (requestPart != null) {
code = MISSING_PART;
parameterName = extractParameterName(requestPart, parameter);
}
CookieValue cookieValue = parameter.getParameterAnnotation(CookieValue.clreplaced);
if (cookieValue != null) {
code = MISSING_COOKIE;
parameterName = extractParameterName(cookieValue, parameter);
}
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
if (matrixVariable != null) {
code = MISSING_MATRIX_VARIABLE;
parameterName = extractParameterName(matrixVariable, parameter);
}
if (code != null) {
return new HandledException(code, BAD_REQUEST, argMap(code, arg("name", parameterName), arg("expected", Clreplacedes.getClreplacedName(parameter.getParameterType()))));
}
return null;
}
18
View Source File : CustomRequestParamMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : yl-yue
License : Apache License 2.0
Project Creator : yl-yue
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestParam ann = parameter.getParameterAnnotation(RequestParam.clreplaced);
return (ann != null ? new RequestParamNamedValueInfo(ann) : new RequestParamNamedValueInfo());
}
18
View Source File : RequestParamMapMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE
License : Apache License 2.0
Project Creator : YeautyYE
@Override
public boolean supportsParameter(MethodParameter parameter) {
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.clreplaced);
return (requestParam != null && Map.clreplaced.isreplacedignableFrom(parameter.getParameterType()) && !StringUtils.hasText(requestParam.name()));
}
18
View Source File : PathVariableMapMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : YeautyYE
License : Apache License 2.0
Project Creator : YeautyYE
@Override
public Object resolveArgument(MethodParameter parameter, Channel channel, Object object) throws Exception {
PathVariable ann = parameter.getParameterAnnotation(PathVariable.clreplaced);
String name = ann.name();
if (name.isEmpty()) {
name = parameter.getParameterName();
if (name == null) {
throw new IllegalArgumentException("Name for argument type [" + parameter.getNestedParameterType().getName() + "] not available, and parameter name information not found in clreplaced file either.");
}
}
Map<String, String> uriTemplateVars = channel.attr(URI_TEMPLATE).get();
if (!CollectionUtils.isEmpty(uriTemplateVars)) {
return uriTemplateVars;
} else {
return Collections.emptyMap();
}
}
18
View Source File : RangeMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : xiangxik
License : Apache License 2.0
Project Creator : xiangxik
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
RangeParam rangeParam = parameter.getParameterAnnotation(RangeParam.clreplaced);
String parameterValue = rangeParam.value();
String value = webRequest.getParameter(parameterValue);
if (Strings.isNullOrEmpty(value)) {
return null;
}
String split = rangeParam.split();
if (!StringUtils.contains(value, split)) {
return null;
}
String[] rangeValues = StringUtils.splitByWholeSeparator(value, split, 2);
@SuppressWarnings("unchecked")
Clreplaced<T> elementClreplaced = (Clreplaced<T>) rangeParam.elementClreplaced();
return new Range<>(conversionService.convert(rangeValues[0], elementClreplaced), conversionService.convert(rangeValues[1], elementClreplaced));
}
18
View Source File : RequestResponseBodyMethodProcessor.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
protected boolean checkRequired(MethodParameter parameter) {
RequestBody requestBody = parameter.getParameterAnnotation(RequestBody.clreplaced);
return (requestBody != null && requestBody.required() && !parameter.isOptional());
}
18
View Source File : RequestAttributeMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestAttribute ann = parameter.getParameterAnnotation(RequestAttribute.clreplaced);
replacedert.state(ann != null, "No RequestAttribute annotation");
return new NamedValueInfo(ann.name(), ann.required(), ValueConstants.DEFAULT_NONE);
}
18
View Source File : MatrixVariableMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public boolean supportsParameter(MethodParameter parameter) {
if (!parameter.hasParameterAnnotation(MatrixVariable.clreplaced)) {
return false;
}
if (Map.clreplaced.isreplacedignableFrom(parameter.nestedIfOptional().getNestedParameterType())) {
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
return (matrixVariable != null && StringUtils.hasText(matrixVariable.name()));
}
return true;
}
18
View Source File : MatrixVariableMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
MatrixVariable ann = parameter.getParameterAnnotation(MatrixVariable.clreplaced);
replacedert.state(ann != null, "No MatrixVariable annotation");
return new MatrixVariableNamedValueInfo(ann);
}
18
View Source File : JsonViewRequestBodyAdvice.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type targetType, Clreplaced<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException {
JsonView ann = methodParameter.getParameterAnnotation(JsonView.clreplaced);
replacedert.state(ann != null, "No JsonView annotation");
Clreplaced<?>[] clreplacedes = ann.value();
if (clreplacedes.length != 1) {
throw new IllegalArgumentException("@JsonView only supported for request body advice with exactly 1 clreplaced argument: " + methodParameter);
}
return new MappingJacksonInputMessage(inputMessage.getBody(), inputMessage.getHeaders(), clreplacedes[0]);
}
18
View Source File : HandlerMethodArgumentResolverSupport.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Evaluate the {@code Predicate} on the method parameter type if it has the
* given annotation, nesting within {@link java.util.Optional} if necessary,
* but raise an {@code IllegalStateException} if the same matches the generic
* type within a reactive type wrapper.
*/
protected <A extends Annotation> boolean checkAnnotatedParamNoReactiveWrapper(MethodParameter parameter, Clreplaced<A> annotationType, BiPredicate<A, Clreplaced<?>> typePredicate) {
A annotation = parameter.getParameterAnnotation(annotationType);
if (annotation == null) {
return false;
}
parameter = parameter.nestedIfOptional();
Clreplaced<?> type = parameter.getNestedParameterType();
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(type);
if (adapter != null) {
replacedertHasValues(adapter, parameter);
parameter = parameter.nested();
type = parameter.getNestedParameterType();
}
if (typePredicate.test(annotation, type)) {
if (adapter == null) {
return true;
}
throw buildReactiveWrapperException(parameter);
}
return false;
}
18
View Source File : RequestBodyMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
public Mono<Object> resolveArgument(MethodParameter param, BindingContext bindingContext, ServerWebExchange exchange) {
RequestBody ann = param.getParameterAnnotation(RequestBody.clreplaced);
replacedert.state(ann != null, "No RequestBody annotation");
return readBody(param, ann.required(), bindingContext, exchange);
}
18
View Source File : ExpressionValueMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
Value ann = parameter.getParameterAnnotation(Value.clreplaced);
replacedert.state(ann != null, "No Value annotation");
return new ExpressionValueNamedValueInfo(ann);
}
18
View Source File : PayloadMethodArgumentResolver.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Decode the content of the given message payload through a compatible
* {@link Decoder}.
*
* <p>Validation is applied if the method argument is annotated with
* {@code @javax.validation.Valid} or
* {@link org.springframework.validation.annotation.Validated}. Validation
* failure results in an {@link MethodArgumentNotValidException}.
*
* @param parameter the target method argument that we are decoding to
* @param message the message from which the content was extracted
* @return a Mono with the result of argument resolution
*
* @see #extractContent(MethodParameter, Message)
* @see #getMimeType(Message)
*/
@Override
public final Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
Payload ann = parameter.getParameterAnnotation(Payload.clreplaced);
if (ann != null && StringUtils.hasText(ann.expression())) {
throw new IllegalStateException("@Payload SpEL expressions not supported by this resolver");
}
MimeType mimeType = getMimeType(message);
mimeType = mimeType != null ? mimeType : MimeTypeUtils.APPLICATION_OCTET_STREAM;
Flux<DataBuffer> content = extractContent(parameter, message);
return decodeContent(parameter, message, ann == null || ann.required(), content, mimeType);
}
18
View Source File : MappingJackson2MessageConverter.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* Determine a Jackson serialization view based on the given conversion hint.
* @param conversionHint the conversion hint Object as preplaceded into the
* converter for the current conversion attempt
* @return the serialization view clreplaced, or {@code null} if none
*/
@Nullable
protected Clreplaced<?> getSerializationView(@Nullable Object conversionHint) {
if (conversionHint instanceof MethodParameter) {
MethodParameter methodParam = (MethodParameter) conversionHint;
JsonView annotation = methodParam.getParameterAnnotation(JsonView.clreplaced);
if (annotation == null) {
annotation = methodParam.getMethodAnnotation(JsonView.clreplaced);
if (annotation == null) {
return null;
}
}
return extractViewClreplaced(annotation, conversionHint);
} else if (conversionHint instanceof JsonView) {
return extractViewClreplaced((JsonView) conversionHint, conversionHint);
} else if (conversionHint instanceof Clreplaced) {
return (Clreplaced<?>) conversionHint;
} else {
return null;
}
}
18
View Source File : ParameterCustomizer.java
License : Apache License 2.0
Project Creator : springdoc
License : Apache License 2.0
Project Creator : springdoc
@Override
public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) {
NotNull annotation = methodParameter.getParameterAnnotation(NotNull.clreplaced);
if (annotation != null) {
parameterModel.required(false);
}
return parameterModel;
}
18
View Source File : RequestBodyService.java
License : Apache License 2.0
Project Creator : springdoc
License : Apache License 2.0
Project Creator : springdoc
/**
* Calculate request body info.
*
* @param components the components
* @param methodAttributes the method attributes
* @param parameterInfo the parameter info
* @param requestBodyInfo the request body info
*/
public void calculateRequestBodyInfo(Components components, MethodAttributes methodAttributes, ParameterInfo parameterInfo, RequestBodyInfo requestBodyInfo) {
RequestBody requestBody = requestBodyInfo.getRequestBody();
MethodParameter methodParameter = parameterInfo.getMethodParameter();
// Get it from parameter level, if not present
if (requestBody == null) {
io.swagger.v3.oas.annotations.parameters.RequestBody requestBodyDoc = methodParameter.getParameterAnnotation(io.swagger.v3.oas.annotations.parameters.RequestBody.clreplaced);
requestBody = this.buildRequestBodyFromDoc(requestBodyDoc, methodAttributes, components).orElse(null);
}
RequestPart requestPart = methodParameter.getParameterAnnotation(RequestPart.clreplaced);
String paramName = null;
if (requestPart != null) {
paramName = StringUtils.defaultIfEmpty(requestPart.value(), requestPart.name());
parameterInfo.setRequired(requestPart.required());
}
paramName = StringUtils.defaultIfEmpty(paramName, parameterInfo.getpName());
parameterInfo.setpName(paramName);
requestBody = buildRequestBody(requestBody, components, methodAttributes, parameterInfo, requestBodyInfo);
requestBodyInfo.setRequestBody(requestBody);
}
18
View Source File : SortHandlerMethodArgumentResolver.java
License : Apache License 2.0
Project Creator : open-hand
License : Apache License 2.0
Project Creator : open-hand
private Sort getDefaultFromAnnotationOrFallback(MethodParameter parameter) {
SortDefaults annotatedDefaults = parameter.getParameterAnnotation(SortDefaults.clreplaced);
SortDefault annotatedDefault = parameter.getParameterAnnotation(SortDefault.clreplaced);
if (annotatedDefault != null && annotatedDefaults != null) {
throw new IllegalArgumentException(String.format("Cannot use both @%s and @%s on parameter %s! Move %s into %s to define sorting order!", SORT_DEFAULTS_NAME, SORT_DEFAULT_NAME, parameter.toString(), SORT_DEFAULT_NAME, SORT_DEFAULTS_NAME));
}
if (annotatedDefault != null) {
return appendOrCreateSortTo(annotatedDefault, null);
}
if (annotatedDefaults != null) {
Sort sort = null;
for (SortDefault currentAnnotatedDefault : annotatedDefaults.value()) {
sort = appendOrCreateSortTo(currentAnnotatedDefault, sort);
}
return sort;
}
return fallbackSort;
}
18
View Source File : LoginUserArgumentResolver.java
License : Apache License 2.0
Project Creator : matevip
License : Apache License 2.0
Project Creator : matevip
@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
EnableUser user = methodParameter.getParameterAnnotation(EnableUser.clreplaced);
boolean value = user.value();
HttpServletRequest request = nativeWebRequest.getNativeRequest(HttpServletRequest.clreplaced);
LoginUser loginUser = SecurityUtil.getUsername(request);
/**
* 根据value状态获取更多用户信息,待实现
*/
return loginUser;
}
See More Examples