Example usage for org.springframework.beans BeanUtils isSimpleProperty

List of usage examples for org.springframework.beans BeanUtils isSimpleProperty

Introduction

In this page you can find the example usage for org.springframework.beans BeanUtils isSimpleProperty.

Prototype

public static boolean isSimpleProperty(Class<?> clazz) 

Source Link

Document

Check if the given type represents a "simple" property: a primitive, a String or other CharSequence, a Number, a Date, a Temporal, a URI, a URL, a Locale, a Class, or a corresponding array.

Usage

From source file:org.springframework.web.method.annotation.ModelAttributeMethodProcessor.java

/**
 * Return {@code true} if there is a method-level {@code @ModelAttribute}
 * or, in default resolution mode, for any return value type that is not
 * a simple type.// ww  w.  ja va 2 s .co m
 */
@Override
public boolean supportsReturnType(MethodParameter returnType) {
    return (returnType.hasMethodAnnotation(ModelAttribute.class)
            || (this.annotationNotRequired && !BeanUtils.isSimpleProperty(returnType.getParameterType())));
}

From source file:org.springframework.web.method.annotation.support.ModelAttributeMethodProcessor.java

/**
 * @return true if the parameter is annotated with {@link ModelAttribute}
 * or in default resolution mode also if it is not a simple type.
 *///from  w w  w  . ja v a2  s  .  c o  m
public boolean supportsParameter(MethodParameter parameter) {
    if (parameter.hasParameterAnnotation(ModelAttribute.class)) {
        return true;
    } else if (this.annotationNotRequired) {
        return !BeanUtils.isSimpleProperty(parameter.getParameterType());
    } else {
        return false;
    }
}

From source file:org.springframework.web.method.annotation.support.ModelAttributeMethodProcessor.java

/**
 * Return {@code true} if there is a method-level {@code @ModelAttribute} 
 * or if it is a non-simple type when {@code annotationNotRequired=true}.
 *//*from   w  ww  .j  a  v a  2s.c o m*/
public boolean supportsReturnType(MethodParameter returnType) {
    if (returnType.getMethodAnnotation(ModelAttribute.class) != null) {
        return true;
    } else if (this.annotationNotRequired) {
        return !BeanUtils.isSimpleProperty(returnType.getParameterType());
    } else {
        return false;
    }
}

From source file:org.tinygroup.springmvc.support.ConventionRestfulWebArgumentResolver.java

@SuppressWarnings("unchecked")
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception {

    if (!isConventionalRestful(webRequest)) {
        return UNRESOLVED;
    }/*w  w w .j a v a  2 s . com*/
    // and the paramName is id
    if (!StringUtils.equals("id", methodParameter.getParameterName())) {
        return UNRESOLVED;
    }

    Map<String, String> uriTemplateVariables = null;
    if (BeanUtils.isSimpleProperty(methodParameter.getParameterType())) {
        uriTemplateVariables = (Map<String, String>) webRequest
                .getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
    }
    if (uriTemplateVariables != null) {
        String val = uriTemplateVariables.get(methodParameter.getParameterName());
        if (val != null && String.class.equals(methodParameter.getParameterType())) {
            return val;
        } else if (val != null) {
            PropertyEditor editor = getDefaultEditor(methodParameter.getParameterType());
            if (editor != null) {
                editor.setAsText(val);
                return editor.getValue();
            }
        }
    }
    return UNRESOLVED;
}