Class DefaultCustomerSegmentValidator<P extends CustomerSegment>

java.lang.Object
com.broadleafcommerce.customer.service.validation.DefaultCustomerSegmentValidator<P>
Type Parameters:
P - A CustomerSegment or subclass of CustomerSegment.
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator

public class DefaultCustomerSegmentValidator<P extends CustomerSegment> extends Object implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Default customer segment validator. Validates that the type of customer segment cannot be modified after creation.
  • Constructor Details

    • DefaultCustomerSegmentValidator

      public DefaultCustomerSegmentValidator()
  • Method Details

    • setCustomerSegmentService

      @Autowired @Lazy public void setCustomerSegmentService(CustomerSegmentService<CustomerSegment> customerSegmentService)
      Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions
      Parameters:
      customerSegmentService - the customer segment service
    • supports

      public boolean supports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      supports in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForReplace

      public void validateForReplace(@NonNull @NonNull Object customerSegment, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      validateForReplace in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForUpdate

      public void validateForUpdate(@NonNull @NonNull Object customerSegment, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      validateForUpdate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateTypeNotChanged

      protected void validateTypeNotChanged(P newCustomerSegment, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates that the replaced customer segment has the same customerSegmentType as the old version.
      Parameters:
      newCustomerSegment - The updated customer segment version.
      errors - Errors object bound to CustomerSegment.
      contextInfo - The current context
    • throwIfErrors

      protected void throwIfErrors(org.springframework.validation.Errors errors)
      Throws a ValidationException if Errors.hasErrors() returns true. May be overridden if throwing a runtime exception is undesirable.
      Parameters:
      errors - The errors object bound to the customer segment that has been validated.
    • getCustomerSegmentService

      protected CustomerSegmentService<CustomerSegment> getCustomerSegmentService()