Class SkuInventoryValidator
java.lang.Object
com.broadleafcommerce.inventory.service.validation.SkuInventoryValidator
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
public class SkuInventoryValidator
extends Object
implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Validator to validate
SkuInventory.- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected InventoryLocationService<InventoryLocation>protected SkuInventoryService<SkuInventory>voidsetInventoryLocationService(InventoryLocationService<InventoryLocation> inventoryLocationService) voidsetSkuInventoryService(SkuInventoryService<SkuInventory> skuInventoryService) booleansupports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) voidvalidate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateAsParentOfSerializedInventory(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryas the parent of serialized inventories, determined bySkuInventory.hasChildren().protected voidvalidateAsSerializedInventory(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryas the serialized inventory itself, determined bySkuInventory.isSerialized().voidvalidateForCreate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) voidvalidateForReplace(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) voidvalidateForUpdate(@NonNull Object updatedBusinessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateInventoryLocation(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateNoDuplicateSkuReferences(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateParentExistsAndSkuRefsMatch(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates the parent of the serializedSkuInventoryexists.protected voidvalidateQuantities(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateQuantitiesForSerializedInventory(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors) Validates that the quantity fields of serializedSkuInventoryis either 0 or 1.protected voidvalidateSerializedInventory(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryfor serialized inventory setup, either the parent or the serialized inventory itself.protected voidvalidateSkuComponent(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateSkuReferencesNotChanged(@NonNull SkuInventory updatedInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory.getSkuRef()is not updated.protected booleanvalidateSkuRefsMatch(@NonNull SkuInventory sku1, @NonNull SkuInventory sku2) Validates that theSkuRefsbetween the two givenSkuInventoriesmatch.
-
Constructor Details
-
SkuInventoryValidator
public SkuInventoryValidator()
-
-
Method Details
-
setSkuInventoryService
@Autowired @Lazy public void setSkuInventoryService(SkuInventoryService<SkuInventory> skuInventoryService) -
setInventoryLocationService
@Autowired @Lazy public void setInventoryLocationService(InventoryLocationService<InventoryLocation> inventoryLocationService) -
supports
public boolean supports(Class<?> serviceClass, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
supportsin interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validate
public void validate(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
validatein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateForCreate
public void validateForCreate(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
validateForCreatein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateForUpdate
public void validateForUpdate(@NonNull @NonNull Object updatedBusinessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
validateForUpdatein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateForReplace
public void validateForReplace(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
validateForReplacein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateSkuComponent
protected void validateSkuComponent(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
validateQuantities
protected void validateQuantities(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
validateSkuReferencesNotChanged
protected void validateSkuReferencesNotChanged(@NonNull @NonNull SkuInventory updatedInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory.getSkuRef()is not updated.- Parameters:
updatedInstance- theSkuInventorythat was updatederrors- an errors object bound to theskuInventoryto be validatedcontext- the current context
-
validateSerializedInventory
protected void validateSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryfor serialized inventory setup, either the parent or the serialized inventory itself.- Parameters:
skuInventory- theSkuInventoryto validateerrors- an errors object bound to theskuInventoryto be validatedcontext- the current context
-
validateAsParentOfSerializedInventory
protected void validateAsParentOfSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryas the parent of serialized inventories, determined bySkuInventory.hasChildren().- Parameters:
skuInventory- theSkuInventoryto validateerrors- An errors object bound to theskuInventoryto be validatedcontext- The current context
-
validateAsSerializedInventory
protected void validateAsSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventoryas the serialized inventory itself, determined bySkuInventory.isSerialized().- Parameters:
skuInventory- theSkuInventoryto validateerrors- An errors object bound to theskuInventoryto be validatedcontext- The current context
-
validateParentExistsAndSkuRefsMatch
protected void validateParentExistsAndSkuRefsMatch(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates the parent of the serializedSkuInventoryexists.- Parameters:
skuInventory- theSkuInventoryto validateerrors- An errors object bound to theskuInventoryto be validatedcontext- The current context
-
validateSkuRefsMatch
protected boolean validateSkuRefsMatch(@NonNull @NonNull SkuInventory sku1, @NonNull @NonNull SkuInventory sku2) Validates that theSkuRefsbetween the two givenSkuInventoriesmatch.Typically used to ensure that the
SkuRefbetween a parent and a serialized inventories match or that theSkuRefisn't updated.SkuRef.getSkuName()is intentionally skipped as it's not used to identify any specific sku inventories. -
validateQuantitiesForSerializedInventory
protected void validateQuantitiesForSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors) Validates that the quantity fields of serializedSkuInventoryis either 0 or 1. -
validateInventoryLocation
protected void validateInventoryLocation(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
validateNoDuplicateSkuReferences
protected void validateNoDuplicateSkuReferences(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
getInventoryLocationService
-
getSkuInventoryService
-