List of usage examples for org.springframework.core MethodParameter getParameterAnnotations
public Annotation[] getParameterAnnotations()
From source file:com.oembedler.moon.graphql.engine.dfs.ResolvableTypeAccessor.java
public static ResolvableTypeAccessor forMethodParameter(Method method, int argIndex, Class<?> implClass) { MethodParameter methodParameter = new MethodParameter(method, argIndex); ResolvableType resolvableType = ResolvableType.forMethodParameter(method, argIndex, implClass); return new ResolvableTypeAccessor("", resolvableType, Lists.newArrayList(methodParameter.getParameterAnnotations()), implClass); }
From source file:springfox.documentation.spring.web.readers.parameter.ParameterTypeReader.java
public static String findParameterType(ParameterContext parameterContext) { MethodParameter methodParameter = parameterContext.methodParameter(); ResolvedMethodParameter resolvedMethodParameter = parameterContext.resolvedMethodParameter(); ResolvedType parameterType = resolvedMethodParameter.getResolvedParameterType(); parameterType = parameterContext.alternateFor(parameterType); //Multi-part file trumps any other annotations if (MultipartFile.class.isAssignableFrom(parameterType.getErasedType())) { return "form"; }/*from ww w. j a va2s . com*/ Annotation[] methodAnnotations = methodParameter.getParameterAnnotations(); for (Annotation annotation : methodAnnotations) { if (annotation instanceof PathVariable) { return "path"; } else if (annotation instanceof ModelAttribute) { return "body"; } else if (annotation instanceof RequestBody) { return "body"; } else if (annotation instanceof RequestParam) { return queryOrForm(parameterContext.getOperationContext()); } else if (annotation instanceof RequestHeader) { return "header"; } else if (annotation instanceof RequestPart) { return "form"; } } return "body"; }
From source file:springfox.documentation.spring.web.readers.parameter.ParameterDefaultReader.java
private String findAnnotatedDefaultValue(MethodParameter methodParameter) { Annotation[] methodAnnotations = methodParameter.getParameterAnnotations(); for (Annotation annotation : methodAnnotations) { if (annotation instanceof RequestParam) { return ((RequestParam) annotation).defaultValue(); } else if (annotation instanceof RequestHeader) { return ((RequestHeader) annotation).defaultValue(); }/*from ww w. j a v a2 s .co m*/ } return null; }
From source file:springfox.documentation.swagger.readers.parameter.ParameterDefaultReader.java
private String findAnnotatedDefaultValue(MethodParameter methodParameter) { Annotation[] methodAnnotations = methodParameter.getParameterAnnotations(); if (null != methodAnnotations) { for (Annotation annotation : methodAnnotations) { if (annotation instanceof ApiParam && hasText(((ApiParam) annotation).defaultValue())) { return ((ApiParam) annotation).defaultValue(); }/*from w w w. j a va2s. c om*/ } } return null; }
From source file:springfox.documentation.swagger.readers.parameter.ParameterRequiredReader.java
private Optional<Boolean> getAnnotatedRequired(MethodParameter methodParameter) { Annotation[] methodAnnotations = methodParameter.getParameterAnnotations(); // when the type is Optional, the required property of @RequestParam/@RequestHeader doesn't matter, // since the value is always a non-null Optional after conversion if (null != methodAnnotations) { for (Annotation annotation : methodAnnotations) { if (annotation instanceof ApiParam) { return Optional.of(((ApiParam) annotation).required()); }/*from w w w . j av a2 s . co m*/ } } return Optional.absent(); }
From source file:springfox.documentation.swagger.readers.parameter.ParameterAllowableReader.java
private String findAnnotatedAllowableValues(MethodParameter methodParameter) { Annotation[] methodAnnotations = methodParameter.getParameterAnnotations(); if (null != methodAnnotations) { for (Annotation annotation : methodAnnotations) { if (annotation instanceof ApiParam) { return ((ApiParam) annotation).allowableValues(); }//from w ww .j av a2 s .c o m } } return null; }
From source file:architecture.user.spring.annotation.ActiveUserWebArgumentResolver.java
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) { Annotation[] annotations = methodParameter.getParameterAnnotations(); if (methodParameter.getParameterType().equals(org.springframework.security.core.userdetails.User.class) || methodParameter.getParameterType() .equals(architecture.user.security.spring.userdetails.ExtendedUserDetails.class)) { for (Annotation annotation : annotations) { if (ActiveUser.class.isInstance(annotation)) { Principal principal = webRequest.getUserPrincipal(); if (principal == null) { return EMPTY_EXTENDED_USER_DETAILS; } else { return ((Authentication) principal).getPrincipal(); }//from ww w . ja v a 2s . c o m } } } return WebArgumentResolver.UNRESOLVED; }
From source file:capital.scalable.restdocs.constraints.MethodParameterValidatorConstraintResolver.java
@Override public List<Constraint> resolveForParameter(MethodParameter param) { List<Constraint> constraints = new ArrayList<>(); for (Annotation annot : param.getParameterAnnotations()) { Class<? extends Annotation> type = annot.annotationType(); if (type.getAnnotation(javax.validation.Constraint.class) != null) { Constraint constraint = createConstraint(annot, type); constraints.add(constraint); }// www. ja v a 2 s .c om } return constraints; }
From source file:net.kaczmarzyk.spring.data.jpa.web.AnnotatedSpecInterfaceArgumentResolver.java
private Specification<Object> resolveSpecFromParameterAnnotations(NativeWebRequest webRequest, MethodParameter parameter) throws Exception { Object specDef = getAnnotation(parameter.getParameterAnnotations()); return specDef != null ? buildSpecification(webRequest, specDef) : null; }
From source file:springfox.documentation.spring.web.readers.parameter.ParameterNameReader.java
private String findParameterNameFromAnnotations(MethodParameter methodParameter) { List<Annotation> methodAnnotations = newArrayList(methodParameter.getParameterAnnotations()); return from(methodAnnotations).filter(PathVariable.class).first().transform(pathVariableValue()) .or(first(methodAnnotations, ModelAttribute.class).transform(modelAttributeValue())) .or(first(methodAnnotations, RequestParam.class).transform(requestParamValue())) .or(first(methodAnnotations, RequestHeader.class).transform(requestHeaderValue())).orNull(); }