Class CompositeUriComponentsContributor
java.lang.Object
org.springframework.web.method.support.CompositeUriComponentsContributor
- All Implemented Interfaces:
UriComponentsContributor
A
UriComponentsContributor
containing a list of other contributors
to delegate to and also encapsulating a specific ConversionService
to
use for formatting method argument values as Strings.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
-
Constructor Summary
ConstructorDescriptionCompositeUriComponentsContributor
(Collection<?> contributors) Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
.CompositeUriComponentsContributor
(Collection<?> contributors, ConversionService cs) Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
.CompositeUriComponentsContributor
(UriComponentsContributor... contributors) Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
contributeMethodArgument
(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables) An overloaded method that uses the ConversionService created at construction.void
contributeMethodArgument
(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) Process the given method argument and either update theUriComponentsBuilder
or add to the map with URI variables to use to expand the URI after all arguments are processed.boolean
Determine if thisCompositeUriComponentsContributor
has any contributors.boolean
supportsParameter
(MethodParameter parameter) Whether this contributor supports the given method parameter.
-
Constructor Details
-
CompositeUriComponentsContributor
Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
. Since both of these tend to be implemented by the same class, the most convenient option is to obtain the configuredHandlerMethodArgumentResolvers
inRequestMappingHandlerAdapter
and provide that to this constructor.- Parameters:
contributors
- a collection ofUriComponentsContributor
orHandlerMethodArgumentResolvers
-
CompositeUriComponentsContributor
Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
. Since both of these tend to be implemented by the same class, the most convenient option is to obtain the configuredHandlerMethodArgumentResolvers
inRequestMappingHandlerAdapter
and provide that to this constructor.- Parameters:
contributors
- a collection ofUriComponentsContributor
orHandlerMethodArgumentResolvers
-
CompositeUriComponentsContributor
public CompositeUriComponentsContributor(@Nullable Collection<?> contributors, @Nullable ConversionService cs) Create an instance from a collection ofUriComponentsContributors
orHandlerMethodArgumentResolvers
. Since both of these tend to be implemented by the same class, the most convenient option is to obtain the configuredHandlerMethodArgumentResolvers
in theRequestMappingHandlerAdapter
and provide that to this constructor.If the
ConversionService
argument isnull
,DefaultFormattingConversionService
will be used by default.- Parameters:
contributors
- a collection ofUriComponentsContributor
orHandlerMethodArgumentResolvers
cs
- a ConversionService to use when method argument values need to be formatted as Strings before being added to the URI
-
-
Method Details
-
hasContributors
public boolean hasContributors()Determine if thisCompositeUriComponentsContributor
has any contributors.- Returns:
true
if thisCompositeUriComponentsContributor
was created with contributors to delegate to
-
supportsParameter
Description copied from interface:UriComponentsContributor
Whether this contributor supports the given method parameter.- Specified by:
supportsParameter
in interfaceUriComponentsContributor
-
contributeMethodArgument
public void contributeMethodArgument(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) Description copied from interface:UriComponentsContributor
Process the given method argument and either update theUriComponentsBuilder
or add to the map with URI variables to use to expand the URI after all arguments are processed.- Specified by:
contributeMethodArgument
in interfaceUriComponentsContributor
- Parameters:
parameter
- the controller method parameter (nevernull
)value
- the argument value (possiblynull
)builder
- the builder to update (nevernull
)uriVariables
- a map to add URI variables to (nevernull
)conversionService
- a ConversionService to format values as Strings
-
contributeMethodArgument
public void contributeMethodArgument(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables) An overloaded method that uses the ConversionService created at construction.
-