Class CodeFormatAvailableCharHelper
java.lang.Object
com.broadleafcommerce.promotion.offer.service.helper.CodeFormatAvailableCharHelper
Determines for a given character what the available replacement characters are.
- Author:
- bpolster
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
countAllowedCharsInFirstPosition
(CodeGenerator generator) long
countCombinationsForGenerator
(CodeGenerator generator) Calculate the number of combinations for the passed in generator object.long
countCombinationsForGenerator
(CodeGenerator generator, int skipCount, boolean firstOnly) Calculate the number of combinations for the passed in generator object.getAvailableCharactersForFormatElement
(CodeGenerator generator, char formatElement) resolveCharMap
(CodeGenerator generator) If the generator has a custom alphabet then use that for the charMap, otherwise, use the default charMap configured in the helper.
-
Field Details
-
CODE_FRIENDLY_NUMBERS
- See Also:
-
CODE_FRIENDLY_LETTERS
- See Also:
-
CODE_FRIENDLY_ALL
- See Also:
-
-
Constructor Details
-
CodeFormatAvailableCharHelper
public CodeFormatAvailableCharHelper()
-
-
Method Details
-
getAvailableCharactersForFormatElement
-
countCombinationsForGenerator
Calculate the number of combinations for the passed in generator object.- Parameters:
generator
- - instance of CodeGenerator to evaluate- Returns:
- The number of unique codes that can be generated with this generator
-
countCombinationsForGenerator
public long countCombinationsForGenerator(CodeGenerator generator, int skipCount, boolean firstOnly) Calculate the number of combinations for the passed in generator object.- Parameters:
generator
- - instance of CodeGenerator to evaluateskipCount
- - the number of characters in the code reserved as a bucket prefixfirstOnly
- - stop counting after the first variable position- Returns:
- The number of unique codes that can be generated with this generator
-
resolveCharMap
If the generator has a custom alphabet then use that for the charMap, otherwise, use the default charMap configured in the helper.- Parameters:
generator
- The CodeGenerator- Returns:
- The character map to use for the alphabet
-
countAllowedCharsInFirstPosition
-