public class DefaultAttributeChoiceConfigurationService extends Object implements AttributeChoiceConfigurationService
Constructor and Description |
---|
DefaultAttributeChoiceConfigurationService(org.springframework.context.MessageSource messageSource,
com.broadleafcommerce.common.extension.TypeFactory typeFactory) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAttributeConfigError(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull String attributeName,
@NonNull String errorCode,
@NonNull String errorMessage) |
protected Optional<String> |
determineChosenValue(@NonNull ProductOption option,
@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
com.broadleafcommerce.cart.client.domain.Cart cart)
Determine the chosen value on the cart item for the provided option.
|
protected Optional<String> |
determineMatchedValue(@NonNull AttributeChoice attributeChoice,
String chosenValue)
If there are any
AttributeChoice.getAllowedValues() , make sure that the chosen value
matches. |
protected String |
getMessage(@NonNull String errorMessage,
Object... args) |
protected org.springframework.context.MessageSource |
getMessageSource() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
protected void |
performRegexValidation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull AttributeChoice attributeChoice,
@NonNull String chosenValue)
Perform regex validation from
AttributeChoice.getValidationRule() against the cart. |
protected void |
performValidationStrategy(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull AttributeChoice attributeChoice,
@NonNull String chosenValue)
Perform the
AttributeChoice.getValidationStrategy() on the cartItem and the chosen
value. |
protected boolean |
shouldPerformValidation(@NonNull String validationFlow,
String validationStrategy)
Whether to perform the
AttributeChoice.getValidationStrategy() for the item for the
current flow. |
void |
validateAttributeChoice(com.broadleafcommerce.cart.client.domain.Cart cart,
@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull String validationFlow,
@NonNull ProductOption option)
Perform validation against the provided
CartItem for the given attribute choice
ProductOption . |
public DefaultAttributeChoiceConfigurationService(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
public void validateAttributeChoice(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull String validationFlow, @NonNull @NonNull ProductOption option)
AttributeChoiceConfigurationService
CartItem
for the given attribute choice
ProductOption
.validateAttributeChoice
in interface AttributeChoiceConfigurationService
cart
- The Cart
of the CartItem
cartItem
- The CartItem
to perform attribute choice
validation against.validationFlow
- The context used to identify validation requirements of the
CartItem
at that point in its lifecycle.option
- The ProductOption
(and it's ProductOption.getAttributeChoice()
we are using to validate the cart against.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)
option
- The option to check the chosen value for.cartItem
- The cart item to check the chosen value on.cart
- The cart with the cartItemprotected boolean shouldPerformValidation(@NonNull @NonNull String validationFlow, @Nullable String validationStrategy)
AttributeChoice.getValidationStrategy()
for the item for the
current flow.validationFlow
- The context used to identify validation requirements of the
CartItem
at that point in its lifecycle.validationStrategy
- The ValidationStrategy
AttributeChoice.getValidationStrategy()
for the item
for the current flow.protected void performValidationStrategy(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull AttributeChoice attributeChoice, @NonNull @NonNull String chosenValue)
AttributeChoice.getValidationStrategy()
on the cartItem and the chosen
value.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.protected void performRegexValidation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull AttributeChoice attributeChoice, @NonNull @NonNull String chosenValue)
AttributeChoice.getValidationRule()
against the cart.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.protected Optional<String> determineMatchedValue(@NonNull @NonNull AttributeChoice attributeChoice, @Nullable String chosenValue)
AttributeChoice.getAllowedValues()
, make sure that the chosen value
matches. Otherwise, the chosen value is returned.attributeChoice
- The attribute choice to check allowed values against.chosenValue
- The chosen value to check against allowed values.AttributeChoice.getAllowedValues()
, make sure that the
chosen value matches. Otherwise, the chosen value is returned.protected void addAttributeConfigError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull String attributeName, @NonNull @NonNull String errorCode, @NonNull @NonNull String errorMessage)
protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
protected org.springframework.context.MessageSource getMessageSource()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Copyright © 2021. All rights reserved.