Package io.micronaut.http.bind.binders
Class QueryValueArgumentBinder<T>
java.lang.Object
io.micronaut.core.bind.annotation.AbstractArgumentBinder<T>
io.micronaut.http.bind.binders.QueryValueArgumentBinder<T>
- Type Parameters:
T
- The argument type
- All Implemented Interfaces:
AnnotatedArgumentBinder<QueryValue,
,T, HttpRequest<?>> ArgumentBinder<T,
,HttpRequest<?>> AnnotatedRequestArgumentBinder<QueryValue,
,T> RequestArgumentBinder<T>
public class QueryValueArgumentBinder<T>
extends AbstractArgumentBinder<T>
implements AnnotatedRequestArgumentBinder<QueryValue,T>
A binder for binding arguments annotated with @QueryValue.
- Since:
- 2.0.2
- Author:
- James Kleeh, Andriy Dmytruk
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.core.bind.ArgumentBinder
ArgumentBinder.BindingResult<T>
-
Field Summary
Fields inherited from class io.micronaut.core.bind.annotation.AbstractArgumentBinder
conversionService
-
Constructor Summary
ConstructorDescriptionQueryValueArgumentBinder
(ConversionService conversionService) Constructor.QueryValueArgumentBinder
(ConversionService conversionService, Argument<T> argument) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbind
(ArgumentConversionContext<T> context, HttpRequest<?> source) Binds the argument withQueryValue
annotation to the request (Also binds without annotation if request body is not permitted).createSpecific
(Argument<T> argument) Create a specific binder.protected String
getParameterName
(Argument<T> argument) Find the parameter name.Methods inherited from class io.micronaut.core.bind.annotation.AbstractArgumentBinder
doBind, doBind, doBind, doBind, doConvert, doConvert, doResolve, doResolve, getFallbackFormat, resolvedParameterName
-
Constructor Details
-
QueryValueArgumentBinder
Constructor.- Parameters:
conversionService
- conversion service
-
QueryValueArgumentBinder
Constructor.- Parameters:
conversionService
- conversion serviceargument
- The argument
-
-
Method Details
-
createSpecific
Description copied from interface:RequestArgumentBinder
Create a specific binder.- Specified by:
createSpecific
in interfaceArgumentBinder<T,
HttpRequest<?>> - Specified by:
createSpecific
in interfaceRequestArgumentBinder<T>
- Parameters:
argument
- The bound argument- Returns:
- The specific binder
-
getAnnotationType
- Specified by:
getAnnotationType
in interfaceAnnotatedArgumentBinder<QueryValue,
T, HttpRequest<?>> - Returns:
- The annotation type.
-
bind
public ArgumentBinder.BindingResult<T> bind(ArgumentConversionContext<T> context, HttpRequest<?> source) Binds the argument withQueryValue
annotation to the request (Also binds without annotation if request body is not permitted).It will first try to convert to ConvertibleMultiValues type and if conversion is successful, add the corresponding parameters to the request. (By default the conversion will be successful if the
Format
annotation is present and has one of the supported values - seeMultiValuesConverterFactory
for specific converters). Otherwise, the uri template will be used to deduce what will be done with the request. For example, simple parameters are converted toString
- 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()
-
getParameterName
Description copied from class:AbstractArgumentBinder
Find the parameter name.- Overrides:
getParameterName
in classAbstractArgumentBinder<T>
- Parameters:
argument
- The argument- Returns:
- The name
-