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
-
Constructor Summary
-
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 aConvertibleValues
for argument spreading.Methods inherited from class io.micronaut.core.bind.annotation.AbstractArgumentBinder
doBind, doBind, doBind, doBind, doConvert, doConvert, doResolve, doResolve, getFallbackFormat, getParameterName, resolvedParameterName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
getAnnotationType
in interfaceAnnotatedArgumentBinder<Body,
T, HttpRequest<?>> - Specified by:
getAnnotationType
in interfaceBodyArgumentBinder<T>
- Returns:
- The required annotation type
-
bind
public final ArgumentBinder.BindingResult<T> bind(ArgumentConversionContext<T> context, HttpRequest<?> source) Description copied from interface:ArgumentBinder
Bind the given argument from the given source.- Specified by:
bind
in interfaceArgumentBinder<T,
HttpRequest<?>> - Parameters:
context
- TheArgumentConversionContext
source
- The source- Returns:
- An
Optional
of 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 aConvertibleValues
for argument spreading.- Parameters:
source
- The request- Returns:
- The body as a
ConvertibleValues
instance
-
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
-