Java Code Examples for org.springframework.web.reactive.BindingContext#getModel()
The following examples show how to use
org.springframework.web.reactive.BindingContext#getModel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelMethodArgumentResolver.java From spring-analysis-note with MIT License | 6 votes |
@Override public Object resolveArgumentValue( MethodParameter parameter, BindingContext context, ServerWebExchange exchange) { Class<?> type = parameter.getParameterType(); if (Model.class.isAssignableFrom(type)) { return context.getModel(); } else if (Map.class.isAssignableFrom(type)) { return context.getModel().asMap(); } else { // Should never happen.. throw new IllegalStateException("Unexpected method parameter type: " + type); } }
Example 2
Source File: ModelArgumentResolver.java From java-technology-stack with MIT License | 6 votes |
@Override public Object resolveArgumentValue( MethodParameter parameter, BindingContext context, ServerWebExchange exchange) { Class<?> type = parameter.getParameterType(); if (Model.class.isAssignableFrom(type)) { return context.getModel(); } else if (Map.class.isAssignableFrom(type)) { return context.getModel().asMap(); } else { // Should never happen.. throw new IllegalStateException("Unexpected method parameter type: " + type); } }
Example 3
Source File: AbstractNamedValueArgumentResolver.java From spring-analysis-note with MIT License | 5 votes |
@Override public Mono<Object> resolveArgument( MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) { NamedValueInfo namedValueInfo = getNamedValueInfo(parameter); MethodParameter nestedParameter = parameter.nestedIfOptional(); Object resolvedName = resolveStringValue(namedValueInfo.name); if (resolvedName == null) { return Mono.error(new IllegalArgumentException( "Specified name must not resolve to null: [" + namedValueInfo.name + "]")); } Model model = bindingContext.getModel(); return resolveName(resolvedName.toString(), nestedParameter, exchange) .flatMap(arg -> { if ("".equals(arg) && namedValueInfo.defaultValue != null) { arg = resolveStringValue(namedValueInfo.defaultValue); } arg = applyConversion(arg, namedValueInfo, parameter, bindingContext, exchange); handleResolvedValue(arg, namedValueInfo.name, parameter, model, exchange); return Mono.justOrEmpty(arg); }) .switchIfEmpty(getDefaultValue( namedValueInfo, parameter, bindingContext, model, exchange)); }
Example 4
Source File: AbstractNamedValueArgumentResolver.java From java-technology-stack with MIT License | 5 votes |
@Override public Mono<Object> resolveArgument( MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) { NamedValueInfo namedValueInfo = getNamedValueInfo(parameter); MethodParameter nestedParameter = parameter.nestedIfOptional(); Object resolvedName = resolveStringValue(namedValueInfo.name); if (resolvedName == null) { return Mono.error(new IllegalArgumentException( "Specified name must not resolve to null: [" + namedValueInfo.name + "]")); } Model model = bindingContext.getModel(); return resolveName(resolvedName.toString(), nestedParameter, exchange) .flatMap(arg -> { if ("".equals(arg) && namedValueInfo.defaultValue != null) { arg = resolveStringValue(namedValueInfo.defaultValue); } arg = applyConversion(arg, namedValueInfo, parameter, bindingContext, exchange); handleResolvedValue(arg, namedValueInfo.name, parameter, model, exchange); return Mono.justOrEmpty(arg); }) .switchIfEmpty(getDefaultValue( namedValueInfo, parameter, bindingContext, model, exchange)); }