Class DefaultCustomerSegmentValidator<P extends CustomerSegment>
java.lang.Object
com.broadleafcommerce.customer.service.validation.DefaultCustomerSegmentValidator<P>
- Type Parameters:
P- ACustomerSegmentor 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CustomerSegmentService<CustomerSegment>voidsetCustomerSegmentService(CustomerSegmentService<CustomerSegment> customerSegmentService) Lazy injection since this validator is itself a service component.booleansupports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidthrowIfErrors(org.springframework.validation.Errors errors) Throws aValidationExceptionifErrors.hasErrors()returns true.voidvalidateForReplace(@NonNull Object customerSegment, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidvalidateForUpdate(@NonNull Object customerSegment, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidvalidateTypeNotChanged(P newCustomerSegment, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that the replaced customer segment has the samecustomerSegmentTypeas the old version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
validate, validateForCreate
-
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:
supportsin interfacecom.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:
validateForReplacein interfacecom.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:
validateForUpdatein interfacecom.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 samecustomerSegmentTypeas the old version.- Parameters:
newCustomerSegment- The updated customer segment version.errors- Errors object bound toCustomerSegment.contextInfo- The current context
-
throwIfErrors
protected void throwIfErrors(org.springframework.validation.Errors errors) Throws aValidationExceptionifErrors.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
-