Class DefaultCustomerSegmentValidator<P extends CustomerSegment>
java.lang.Object
com.broadleafcommerce.customer.service.validation.DefaultCustomerSegmentValidator<P>
- Type Parameters:
P
- ACustomerSegment
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CustomerSegmentService<CustomerSegment>
void
setCustomerSegmentService
(CustomerSegmentService<CustomerSegment> customerSegmentService) Lazy injection since this validator is itself a service component.boolean
supports
(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
throwIfErrors
(org.springframework.validation.Errors errors) Throws aValidationException
ifErrors.hasErrors()
returns true.void
validateForReplace
(@NonNull Object customerSegment, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
validateForUpdate
(@NonNull Object customerSegment, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
validateTypeNotChanged
(P newCustomerSegment, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that the replaced customer segment has the samecustomerSegmentType
as the old version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
supports
in 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:
validateForReplace
in 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:
validateForUpdate
in 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 samecustomerSegmentType
as 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 aValidationException
ifErrors.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
-