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 an EntityMissingException 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

    Modifier and Type
    Method
    Description
    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
    protected boolean
    isRequired(org.springframework.core.MethodParameter param)
    Tells if the given parameter is required.
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CartHandlerMethodArgumentResolver

      public CartHandlerMethodArgumentResolver(CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder)
  • Method Details

    • 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