Package org.springframework.core

Examples of org.springframework.core.MethodParameter


        return getMethodParameter("showUserAnnotation", Object.class);
    }

    private MethodParameter getMethodParameter(String methodName, Class<?>... paramTypes) {
        Method method = ReflectionUtils.findMethod(TestController.class, methodName,paramTypes);
        return new MethodParameter(method,0);
    }
View Full Code Here


      boolean hasUnqualifiedMapParameter = false;
      for (int i = 0; i < parameterTypes.length; i++) {
        if (i != 0) {
          sb.append(", ");
        }
        MethodParameter methodParameter = new MethodParameter(method, i);
        TypeDescriptor parameterTypeDescriptor = new TypeDescriptor(methodParameter);
        Class<?> parameterType = parameterTypeDescriptor.getObjectType();
        Annotation mappingAnnotation = findMappingAnnotation(parameterAnnotations[i]);
        if (mappingAnnotation != null) {
          Class<? extends Annotation> annotationType = mappingAnnotation.annotationType();
View Full Code Here

        try {
          // Pass full property name and old value in here, since we want full
          // conversion ability for map values.
          convertedMapValue = this.typeConverterDelegate.convertIfNecessary(
              propertyName, oldValue, pv.getValue(), mapValueType, null,
              new MethodParameter(pd.getReadMethod(), -1, tokens.keys.length + 1));
        }
        catch (IllegalArgumentException ex) {
          PropertyChangeEvent pce =
              new PropertyChangeEvent(this.rootObject, this.nestedPath + propertyName, oldValue, pv.getValue());
          throw new TypeMismatchException(pce, mapValueType, ex);
View Full Code Here

    if (this.propertyType == null) {
      if (this.readMethod != null) {
        this.propertyType = GenericTypeResolver.resolveReturnType(this.readMethod, this.beanClass);
      }
      else {
        MethodParameter writeMethodParam = getWriteMethodParameter();
        if (writeMethodParam != null) {
          this.propertyType = writeMethodParam.getParameterType();
        }
        else {
          this.propertyType = super.getPropertyType();
        }
      }
View Full Code Here

  public synchronized MethodParameter getWriteMethodParameter() {
    if (this.writeMethod == null) {
      return null;
    }
    if (this.writeMethodParameter == null) {
      this.writeMethodParameter = new MethodParameter(this.writeMethod, 0);
      GenericTypeResolver.resolveParameterType(this.writeMethodParameter, this.beanClass);
    }
    return this.writeMethodParameter;
  }
View Full Code Here

   * @param pd the PropertyDescriptor for the property
   * @return a corresponding MethodParameter object
   */
  public static MethodParameter getWriteMethodParameter(PropertyDescriptor pd) {
    if (pd instanceof GenericTypeAwarePropertyDescriptor) {
      return new MethodParameter(
          ((GenericTypeAwarePropertyDescriptor) pd).getWriteMethodParameter());
    }
    else {
      return new MethodParameter(pd.getWriteMethod(), 0);
    }
  }
View Full Code Here

    Class[] paramTypes = handlerMethod.getParameterTypes();
    Object[] args = new Object[paramTypes.length];

    for (int i = 0; i < args.length; i++) {
      MethodParameter methodParam = new MethodParameter(handlerMethod, i);
      methodParam.initParameterNameDiscovery(this.parameterNameDiscoverer);
      GenericTypeResolver.resolveParameterType(methodParam, handler.getClass());
      String paramName = null;
      boolean paramRequired = false;
      String attrName = null;
      Object[] paramAnns = methodParam.getParameterAnnotations();

      for (int j = 0; j < paramAnns.length; j++) {
        Object paramAnn = paramAnns[j];
        if (RequestParam.class.isInstance(paramAnn)) {
          RequestParam requestParam = (RequestParam) paramAnn;
          paramName = requestParam.value();
          paramRequired = requestParam.required();
          break;
        }
        else if (ModelAttribute.class.isInstance(paramAnn)) {
          ModelAttribute attr = (ModelAttribute) paramAnn;
          attrName = attr.value();
        }
      }
      if (paramName != null && attrName != null) {
        throw new IllegalStateException("@RequestParam and @ModelAttribute are an exclusive choice -" +
            "do not specify both on the same parameter: " + handlerMethod);
      }

      Class paramType = methodParam.getParameterType();

      if (paramName == null && attrName == null) {
        Object argValue = resolveCommonArgument(methodParam, webRequest);
        if (argValue != WebArgumentResolver.UNRESOLVED) {
          args[i] = argValue;
View Full Code Here

    Class[] initBinderParams = initBinderMethod.getParameterTypes();
    Object[] initBinderArgs = new Object[initBinderParams.length];

    for (int i = 0; i < initBinderArgs.length; i++) {
      MethodParameter methodParam = new MethodParameter(initBinderMethod, i);
      methodParam.initParameterNameDiscovery(this.parameterNameDiscoverer);
      GenericTypeResolver.resolveParameterType(methodParam, handler.getClass());
      String paramName = null;
      boolean paramRequired = false;
      Object[] paramAnns = methodParam.getParameterAnnotations();

      for (int j = 0; j < paramAnns.length; j++) {
        Object paramAnn = paramAnns[j];
        if (RequestParam.class.isInstance(paramAnn)) {
          RequestParam requestParam = (RequestParam) paramAnn;
View Full Code Here

      super(field, true);
      this.resourceType = resourceType;
    }

    public ResourceDependencyDescriptor(Method method, Class resourceType) {
      super(new MethodParameter(method, 0), true);
      this.resourceType = resourceType;
    }
View Full Code Here

      return ((BeanWrapperImpl) converter).convertForProperty(value, propertyName);
    }
    else {
      PropertyDescriptor descriptor = bw.getPropertyDescriptor(propertyName);
      return converter.convertIfNecessary(
          value, descriptor.getPropertyType(), new MethodParameter(descriptor.getWriteMethod(), 0));
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.MethodParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.