Package io.micronaut.http.bind.binders
Class DefaultBodyAnnotationBinder<T>
java.lang.Object
io.micronaut.core.bind.annotation.AbstractArgumentBinder<T>
io.micronaut.http.bind.binders.DefaultBodyAnnotationBinder<T>
- Type Parameters:
T- A type
- All Implemented Interfaces:
AnnotatedArgumentBinder<Body,,T, HttpRequest<?>> ArgumentBinder<T,,HttpRequest<?>> AnnotatedRequestArgumentBinder<Body,,T> BodyArgumentBinder<T>,RequestArgumentBinder<T>
@Singleton
public class DefaultBodyAnnotationBinder<T>
extends AbstractArgumentBinder<T>
implements BodyArgumentBinder<T>
Binds a String body argument.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.core.bind.ArgumentBinder
ArgumentBinder.BindingResult<T> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ArgumentBinder.BindingResult<T>bind(ArgumentConversionContext<T> context, HttpRequest<?> source) Bind the given argument from the given source.protected ArgumentBinder.BindingResult<T>bindBodyPart(ArgumentConversionContext<T> context, HttpRequest<?> source, String bodyComponent) Bind a part of the body, for argument spreading.bindFullBody(ArgumentConversionContext<T> context, HttpRequest<?> source) Try to bind from the full body of the request, i.e.protected ArgumentBinder.BindingResult<ConvertibleValues<?>>bindFullBodyConvertibleValues(HttpRequest<?> source) Try to bind from the full body of the request to aConvertibleValuesfor argument spreading.Methods inherited from class io.micronaut.core.bind.annotation.AbstractArgumentBinder
doBind, doBind, doBind, doBind, doConvert, doConvert, doResolve, doResolve, getFallbackFormat, getParameterName, resolvedParameterNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.http.bind.binders.RequestArgumentBinder
createSpecific
-
Field Details
-
conversionService
-
-
Constructor Details
-
DefaultBodyAnnotationBinder
- Parameters:
conversionService- The conversion service
-
-
Method Details
-
getAnnotationType
- Specified by:
getAnnotationTypein interfaceAnnotatedArgumentBinder<Body,T, HttpRequest<?>> - Specified by:
getAnnotationTypein interfaceBodyArgumentBinder<T>- Returns:
- The required annotation type
-
bind
public final ArgumentBinder.BindingResult<T> bind(ArgumentConversionContext<T> context, HttpRequest<?> source) Description copied from interface:ArgumentBinderBind the given argument from the given source.- Specified by:
bindin interfaceArgumentBinder<T,HttpRequest<?>> - Parameters:
context- TheArgumentConversionContextsource- The source- Returns:
- An
Optionalof the value. If no binding was possibleOptional.empty()
-
bindBodyPart
protected ArgumentBinder.BindingResult<T> bindBodyPart(ArgumentConversionContext<T> context, HttpRequest<?> source, String bodyComponent) Bind a part of the body, for argument spreading. By default, this gets the argument frombindFullBodyConvertibleValues(HttpRequest).- Parameters:
context- The context to convert withsource- The requestbodyComponent- The name of the component to bind to- Returns:
- The binding result
-
bindFullBodyConvertibleValues
protected ArgumentBinder.BindingResult<ConvertibleValues<?>> bindFullBodyConvertibleValues(HttpRequest<?> source) Try to bind from the full body of the request to aConvertibleValuesfor argument spreading.- Parameters:
source- The request- Returns:
- The body as a
ConvertibleValuesinstance
-
bindFullBody
public ArgumentBinder.BindingResult<T> bindFullBody(ArgumentConversionContext<T> context, HttpRequest<?> source) Try to bind from the full body of the request, i.e. no argument spreading.- Parameters:
context- The conversion contextsource- The request- Returns:
- The binding result
-