Class SortPositionRequestHandlerMethodArgumentResolver
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.sort.SortPositionRequestHandlerMethodArgumentResolver
-
- All Implemented Interfaces:
org.springframework.web.method.support.HandlerMethodArgumentResolver
public class SortPositionRequestHandlerMethodArgumentResolver extends Object implements org.springframework.web.method.support.HandlerMethodArgumentResolver
Allows the use ofSortPositionRequest
within@RequestMapping
method parameters. Construction of this parameter object requires the requesting URL specify an {id} path variable, and an optional "after" request parameter. This can be used in conjunction with the annotationUpdateSortOperation
to control the names of the id path variable and the "after" request parameter.By default, this will only populate a
SortPositionRequest
if the method parameter does not have theRequestBody
annotation. If it does, then a properly JSON serialized version ofSortPositionRequest
should be provided in the request body. The id path variable and "after" request parameter will both be ignored, then.- Author:
- Jeff Fischer, Nathan Moore (nathandmoore)
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_AFTER_ID_NAME
static String
DEFAULT_BEFORE_ID_NAME
static String
DEFAULT_UPDATE_ID_NAME
-
Constructor Summary
Constructors Constructor Description SortPositionRequestHandlerMethodArgumentResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SortPositionRequest
buildSortPositionRequest(org.springframework.web.context.request.NativeWebRequest req, String updateIdName, String afterIdName, String beforeIdName)
protected String
getDefaultAfterIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.positionAfterContextId
.protected String
getDefaultBeforeIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.positionBeforeContextId
.protected String
getDefaultUpdateIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.updateContextId
.protected Map<String,String>
getPathVariables(org.springframework.web.context.request.NativeWebRequest webRequest)
Object
resolveArgument(org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
boolean
supportsParameter(org.springframework.core.MethodParameter parameter)
-
-
-
Field Detail
-
DEFAULT_UPDATE_ID_NAME
public static final String DEFAULT_UPDATE_ID_NAME
- See Also:
- Constant Field Values
-
DEFAULT_AFTER_ID_NAME
public static final String DEFAULT_AFTER_ID_NAME
- See Also:
- Constant Field Values
-
DEFAULT_BEFORE_ID_NAME
public static final String DEFAULT_BEFORE_ID_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
supportsParameter
public boolean supportsParameter(@NonNull org.springframework.core.MethodParameter parameter)
- Specified by:
supportsParameter
in interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver
-
resolveArgument
public Object resolveArgument(org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
- Specified by:
resolveArgument
in interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver
-
getDefaultUpdateIdName
@NonNull protected String getDefaultUpdateIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.updateContextId
.- Returns:
- default value for the name of the path variable from which to populated
SortPositionRequest.updateContextId
.
-
getDefaultAfterIdName
@NonNull protected String getDefaultAfterIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.positionAfterContextId
.- Returns:
- default value for the name of the URL parameter from which to populated
SortPositionRequest.positionAfterContextId
.
-
getDefaultBeforeIdName
@NonNull protected String getDefaultBeforeIdName()
IfUpdateSortOperation
is missing on the method parameter, this is used to supply a default value forSortPositionRequest.positionBeforeContextId
.- Returns:
- default value for the name of the URL parameter from which to populated
SortPositionRequest.positionBeforeContextId
.
-
buildSortPositionRequest
@NonNull protected SortPositionRequest buildSortPositionRequest(org.springframework.web.context.request.NativeWebRequest req, String updateIdName, String afterIdName, String beforeIdName)
-
-