Search in sources :

Example 21 with BeanMetadata

use of cn.taketoday.beans.BeanMetadata in project today-framework by TAKETODAY.

the class DataBinderParameterResolver method resolveParameter.

/**
 * @return Pojo parameter
 */
@Override
public Object resolveParameter(final RequestContext context, final ResolvableMethodParameter resolvable) throws Throwable {
    final Class<?> parameterClass = resolvable.getParameterType();
    BeanMetadata beanMetadata = BeanMetadata.from(parameterClass);
    Object target = beanMetadata.newInstance();
    RequestContextDataBinder dataBinder = new RequestContextDataBinder(target, resolvable.getName());
    dataBinder.setConversionService(conversionService);
    dataBinder.bind(context);
    // #30 Support annotation-supported in the form of DataBinder
    resolveAnnotatedProperty(context, resolvable, dataBinder);
    // todo dataBinder.validate();
    return target;
}
Also used : BeanMetadata(cn.taketoday.beans.BeanMetadata) RequestContextDataBinder(cn.taketoday.web.bind.RequestContextDataBinder)

Aggregations

BeanMetadata (cn.taketoday.beans.BeanMetadata)21 RequestContextDataBinder (cn.taketoday.web.bind.RequestContextDataBinder)7 Map (java.util.Map)6 PropertyValue (cn.taketoday.beans.PropertyValue)4 PropertyValues (cn.taketoday.beans.PropertyValues)4 MultiValueMap (cn.taketoday.core.MultiValueMap)4 List (java.util.List)4 BeanProperty (cn.taketoday.beans.BeanProperty)2 SimpleTypeConverter (cn.taketoday.beans.SimpleTypeConverter)2 MethodParameter (cn.taketoday.core.MethodParameter)2 ResolvableType (cn.taketoday.core.ResolvableType)2 ResolvableMethodParameter (cn.taketoday.web.handler.method.ResolvableMethodParameter)2 Test (org.junit.jupiter.api.Test)2