Class 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 an EntityMissingException for methods where the Cart parameter is not marked as nullable and the cart could not be determined.
    Author:
    Chris Kittrell
    • 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 interface org.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 interface org.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 of Nullable 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 test
        annotationClass - the annotation class to test the presence of
        Returns:
        true if the parameter has the given annotation, false otherwise