Class CodeGeneratorPreValidator
- java.lang.Object
-
- com.broadleafcommerce.promotion.campaign.service.validation.CodeGeneratorPreValidator
-
public class CodeGeneratorPreValidator extends Object
Validation ran on aCodeGenerator
before create. This is a separate validation fromCodeGeneratorValidator
which is an entity validator that runs at a later phase. This component is specifically used inDefaultCodeGeneratorService
to test the input provided by an API caller before any initialization logic kicks in.
-
-
Constructor Summary
Constructors Constructor Description CodeGeneratorPreValidator(CampaignService<Campaign> campaignService, CodeFormatAvailableCharHelper availableCharHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
calculateRequiredCodeLength(int numberOfCodes, int charSetSize)
Returns the size of the code that you must create in order to support the passed in number of Codes.protected CodeFormatAvailableCharHelper
getAvailableCharHelper()
protected CampaignService<Campaign>
getCampaignService()
protected int
getCodeMultiplier()
Affects the "guessability" of codes when a code format has not been provided.void
prevalidateForCreate(CodeGenerator codeGenerator, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Validates that the input provided by an API caller before any initialization logic is performed
-
-
-
Constructor Detail
-
CodeGeneratorPreValidator
public CodeGeneratorPreValidator(CampaignService<Campaign> campaignService, CodeFormatAvailableCharHelper availableCharHelper)
-
-
Method Detail
-
prevalidateForCreate
public void prevalidateForCreate(@NonNull CodeGenerator codeGenerator, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Validates that the input provided by an API caller before any initialization logic is performed- Parameters:
codeGenerator
- theCodeGenerator
that is validated before createerrors
- Errors object for tracking any errorscontext
- context surrounding sandboxing and multitenant state
-
calculateRequiredCodeLength
protected int calculateRequiredCodeLength(int numberOfCodes, int charSetSize)
Returns the size of the code that you must create in order to support the passed in number of Codes.- Parameters:
numberOfCodes
-- Returns:
-
getCodeMultiplier
protected int getCodeMultiplier()
Affects the "guessability" of codes when a code format has not been provided. For example, if 100 codes are being generated, the default will insure that the codes are generated at least from a pool of 100000 possible codes.- Returns:
-
getCampaignService
@NonNull protected CampaignService<Campaign> getCampaignService()
-
getAvailableCharHelper
@NonNull protected CodeFormatAvailableCharHelper getAvailableCharHelper()
-
-