Package io.micronaut.http.bind.binders
Class RequestAttributeAnnotationBinder<T>
java.lang.Object
io.micronaut.core.bind.annotation.AbstractArgumentBinder<T>
io.micronaut.http.bind.binders.RequestAttributeAnnotationBinder<T>
- Type Parameters:
T
- A type
- All Implemented Interfaces:
AnnotatedArgumentBinder<RequestAttribute,
,T, HttpRequest<?>> ArgumentBinder<T,
,HttpRequest<?>> AnnotatedRequestArgumentBinder<RequestAttribute,
,T> PostponedRequestArgumentBinder<T>
,RequestArgumentBinder<T>
public class RequestAttributeAnnotationBinder<T>
extends AbstractArgumentBinder<T>
implements AnnotatedRequestArgumentBinder<RequestAttribute,T>, PostponedRequestArgumentBinder<T>
An
AnnotatedArgumentBinder
implementation that uses the RequestAttribute
annotation to trigger binding from an HTTP request attribute.
NOTE: The binder is annotating as postponed to allow injecting attributes added by filters.- Author:
- Ahmed Lafta
- See Also:
-
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
ConstructorDescriptionRequestAttributeAnnotationBinder
(ConversionService conversionService) RequestAttributeAnnotationBinder
(ConversionService conversionService, Argument<T> argument) -
Method Summary
Modifier and TypeMethodDescriptionbind
(ArgumentConversionContext<T> argument, HttpRequest<?> source) Bind the given argument from the given source.createSpecific
(Argument<T> argument) Create a specific binder.protected String
getFallbackFormat
(Argument<?> argument) 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, 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.PostponedRequestArgumentBinder
bindPostponed
-
Constructor Details
-
RequestAttributeAnnotationBinder
- Parameters:
conversionService
- conversionService
-
RequestAttributeAnnotationBinder
- Parameters:
conversionService
- conversionServiceargument
- 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<RequestAttribute,
T, HttpRequest<?>> - Returns:
- The annotation type.
-
bind
public ArgumentBinder.BindingResult<T> bind(ArgumentConversionContext<T> argument, HttpRequest<?> source) Description copied from interface:ArgumentBinder
Bind the given argument from the given source.- Specified by:
bind
in interfaceArgumentBinder<T,
HttpRequest<?>> - Parameters:
argument
- 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
-
getFallbackFormat
- Overrides:
getFallbackFormat
in classAbstractArgumentBinder<T>
- Parameters:
argument
- The argument- Returns:
- The fallback format
-