List of usage examples for org.springframework.core MethodParameter hasParameterAnnotation
public <A extends Annotation> boolean hasParameterAnnotation(Class<A> annotationType)
From source file:net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolver.java
@Override public boolean supportsParameter(MethodParameter param) { return param.getParameterType() == Specification.class && param.hasParameterAnnotation(Spec.class); }
From source file:com.kingray.spring.mvc.method.annotation.RequestJsonParamMethodArgumentResolver.java
public boolean supportsParameter(MethodParameter parameter) { if (parameter.hasParameterAnnotation(RequestJsonParam.class)) { return true; }/*w w w . j av a 2 s . c o m*/ return false; }
From source file:org.focusns.common.web.widget.mvc.method.WidgetMethodArgumentResolver.java
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { ///*from ww w .ja va 2 s . c o m*/ Object value = null; if (parameter.hasParameterAnnotation(WidgetAttribute.class)) { value = getWidgetAttributeValue(parameter, webRequest); } else if (parameter.hasParameterAnnotation(WidgetPref.class)) { value = getWidgetPrefValue(parameter, webRequest); } // if (value != null) { ConversionService conversionService = (ConversionService) webRequest .getAttribute(ConversionService.class.getName(), WebRequest.SCOPE_REQUEST); if (conversionService.canConvert(value.getClass(), parameter.getParameterType())) { value = conversionService.convert(value, parameter.getParameterType()); } else { throw new ConverterNotFoundException(TypeDescriptor.forObject(value), TypeDescriptor.valueOf(parameter.getParameterType())); } } // return value; }
From source file:com.redblackit.web.server.mvc.RequestUrlHandlerMethodArgumentResolver.java
/** * Check for parameter type support. Note if the annotation is present, we * throw an exception if the annotation is applied to an invalid type. * * @param methodParameter// w ww . j a v a 2s .co m * @return true if supported, false if not */ @Override public boolean supportsParameter(MethodParameter methodParameter) { final Class<?> paramType = methodParameter.getParameterType(); boolean isSupported = UrlChildLocation.class.isAssignableFrom(paramType); if (!isSupported) { if (methodParameter.hasParameterAnnotation(RequestUrl.class)) { isSupported = String.class.isAssignableFrom(paramType) || StringBuffer.class.isAssignableFrom(paramType) || StringBuilder.class.isAssignableFrom(paramType) || URL.class.isAssignableFrom(paramType) || URI.class.isAssignableFrom(paramType); if (!isSupported) { throw new IllegalStateException("methodParameter[" + methodParameter.getParameterIndex() + "] type=" + paramType + ":not compatible with @RequestUrl annotation:must be String, StringBuffer, StringBuilder, URL or URI"); } } } return isSupported; }
From source file:org.zht.framework.web.bind.resolver.FormModelMethodArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter parameter) { if (parameter.hasParameterAnnotation(FormModel.class)) { return true; }//from w w w . j a v a2s . c om return false; }
From source file:com.fengduo.bee.commons.component.FormModelMethodArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter parameter) { return parameter.hasParameterAnnotation(FormBean.class); }
From source file:dstrelec.nats.listener.adapter.MessagingMessageListenerAdapter.java
/** * Subclasses can override this method to use a different mechanism to determine * the target type of the payload conversion. * @param method the method./*w ww . ja v a 2 s . co m*/ * @return the type. */ protected Type determineInferredType(Method method) { if (method == null) { return null; } Type genericParameterType = null; for (int i = 0; i < method.getParameterTypes().length; i++) { MethodParameter methodParameter = new MethodParameter(method, i); /* * We're looking for a single non-annotated parameter, or one annotated with @Payload. * We ignore parameters with type Message because they are not involved with conversion. */ if (eligibleParameter(methodParameter) && (methodParameter.getParameterAnnotations().length == 0 || methodParameter.hasParameterAnnotation(Payload.class))) { if (genericParameterType == null) { genericParameterType = methodParameter.getGenericParameterType(); if (genericParameterType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) genericParameterType; if (parameterizedType.getRawType().equals(Message.class)) { genericParameterType = ((ParameterizedType) genericParameterType) .getActualTypeArguments()[0]; } else if (parameterizedType.getRawType().equals(List.class) && parameterizedType.getActualTypeArguments().length == 1) { Type paramType = parameterizedType.getActualTypeArguments()[0]; this.isConsumerRecordList = paramType.equals(io.nats.client.Message.class) || (paramType instanceof ParameterizedType && ((ParameterizedType) paramType) .getRawType().equals(io.nats.client.Message.class)); this.isMessageList = paramType.equals(Message.class) || (paramType instanceof ParameterizedType && ((ParameterizedType) paramType).getRawType().equals(Message.class)); } } } else { if (this.logger.isDebugEnabled()) { this.logger.debug("Ambiguous parameters for target payload for method " + method + "; no inferred type available"); } break; } } } Assert.state(!this.isConsumerRecordList || method.getParameterTypes().length == 1, "A parameter of type 'List<ConsumerRecord>' must be the only parameter"); Assert.state(!this.isMessageList || method.getParameterTypes().length == 1, "A parameter of type 'List<Message<?>>' must be the only parameter"); return genericParameterType; }
From source file:org.simbasecurity.manager.service.rest.resolver.JSonArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter methodParameter) { return methodParameter.hasParameterAnnotation(JsonBody.class); }
From source file:org.springframework.cloud.aws.messaging.endpoint.NotificationMessageHandlerMethodArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter parameter) { return (parameter.hasParameterAnnotation(NotificationMessage.class)); }
From source file:org.springframework.cloud.aws.messaging.endpoint.NotificationSubjectHandlerMethodArgumentResolver.java
@Override public boolean supportsParameter(MethodParameter parameter) { return (parameter.hasParameterAnnotation(NotificationSubject.class) && ClassUtils.isAssignable(String.class, parameter.getParameterType())); }