Class CartHandlerMethodArgumentResolver
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.web.resolver.CartHandlerMethodArgumentResolver
-
- All Implemented Interfaces:
org.springframework.web.method.support.HandlerMethodArgumentResolver
public class CartHandlerMethodArgumentResolver extends Object implements org.springframework.web.method.support.HandlerMethodArgumentResolver
Resolves the Cart parameter for controller methods that require it. This will throw anEntityMissingException
for methods where the Cart parameter is not marked as nullable and the cart could not be determined.- Author:
- Chris Kittrell
-
-
Constructor Summary
Constructors Constructor Description CartHandlerMethodArgumentResolver(CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <A extends Annotation>
booleanhasAnnotation(org.springframework.core.MethodParameter param, Class<A> annotationClass)
Tells whether the method parameter has the given annotation on itprotected boolean
isRequired(org.springframework.core.MethodParameter param)
Tells if the given parameter is required.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)
-
-
-
Constructor Detail
-
CartHandlerMethodArgumentResolver
public CartHandlerMethodArgumentResolver(CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder)
-
-
Method Detail
-
supportsParameter
public boolean supportsParameter(org.springframework.core.MethodParameter parameter)
- Specified by:
supportsParameter
in interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver
-
resolveArgument
public Object resolveArgument(@NonNull org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, @NonNull org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
- Specified by:
resolveArgument
in interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver
-
isRequired
protected boolean isRequired(org.springframework.core.MethodParameter param)
Tells if the given parameter is required. Determine by the presence ofNullable
annotations on the parameter.- Parameters:
param
- the method parameter to test- Returns:
- true if required, false if optional
-
hasAnnotation
protected <A extends Annotation> boolean hasAnnotation(org.springframework.core.MethodParameter param, Class<A> annotationClass)
Tells whether the method parameter has the given annotation on it- Type Parameters:
A
- some annotation class- Parameters:
param
- the method parameter to testannotationClass
- the annotation class to test the presence of- Returns:
- true if the parameter has the given annotation, false otherwise
-
-