Class DefaultAttributeChoiceConfigurationService

    • Constructor Detail

      • DefaultAttributeChoiceConfigurationService

        public DefaultAttributeChoiceConfigurationService​(org.springframework.context.MessageSource messageSource,
                                                          com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • Method Detail

      • determineChosenValue

        protected Optional<String> determineChosenValue​(@NonNull
                                                        @NonNull ProductOption option,
                                                        @NonNull
                                                        @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                                        @Nullable
                                                        com.broadleafcommerce.cart.client.domain.Cart cart)
        Determine the chosen value on the cart item for the provided option.
        Parameters:
        option - The option to check the chosen value for.
        cartItem - The cart item to check the chosen value on.
        cart - The cart with the cartItem
        Returns:
        The chosen value on the cart item for the provided option.
      • performValidationStrategy

        protected void performValidationStrategy​(@NonNull
                                                 @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                                 @NonNull
                                                 @NonNull AttributeChoice attributeChoice,
                                                 @NonNull
                                                 @NonNull String chosenValue)
        Perform the AttributeChoice.getValidationStrategy() on the cartItem and the chosen value.
        Parameters:
        cartItem - The cart item to perform the validation strategy against.
        attributeChoice - The attribute choice to use to perform the validation strategy.
        chosenValue - The determined chosen value from the cart item for the attribute choice.
      • performRegexValidation

        protected void performRegexValidation​(@NonNull
                                              @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                              @NonNull
                                              @NonNull AttributeChoice attributeChoice,
                                              @NonNull
                                              @NonNull String chosenValue)
        Perform regex validation from AttributeChoice.getValidationRule() against the cart.
        Parameters:
        cartItem - The cart item to perform regex validation against.
        attributeChoice - The attribute choice to use to perform the validation strategy.
        chosenValue - The determined chosen value from the cart item for the attribute choice.
      • determineMatchedValue

        protected Optional<String> determineMatchedValue​(@NonNull
                                                         @NonNull AttributeChoice attributeChoice,
                                                         @Nullable
                                                         String chosenValue)
        If there are any AttributeChoice.getAllowedValues(), make sure that the chosen value matches. Otherwise, the chosen value is returned.
        Parameters:
        attributeChoice - The attribute choice to check allowed values against.
        chosenValue - The chosen value to check against allowed values.
        Returns:
        If there are any AttributeChoice.getAllowedValues(), make sure that the chosen value matches. Otherwise, the chosen value is returned.
      • addAttributeConfigError

        protected void addAttributeConfigError​(@NonNull
                                               @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                               @NonNull
                                               @NonNull String attributeName,
                                               @NonNull
                                               @NonNull String errorCode,
                                               @NonNull
                                               @NonNull String errorMessage)
      • getMessage

        protected String getMessage​(@NonNull
                                    @NonNull String errorMessage,
                                    @Nullable
                                    Object... args)
      • getMessageSource

        protected org.springframework.context.MessageSource getMessageSource()
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()