Class CodeFormatAvailableCharHelper
- java.lang.Object
-
- com.broadleafcommerce.promotion.campaign.service.helper.CodeFormatAvailableCharHelper
-
public class CodeFormatAvailableCharHelper extends Object
Determines for a given character what the available replacement characters are.- Author:
- bpolster
-
-
Field Summary
Fields Modifier and Type Field Description static StringCODE_FRIENDLY_ALLstatic StringCODE_FRIENDLY_LETTERSstatic StringCODE_FRIENDLY_NUMBERS
-
Constructor Summary
Constructors Constructor Description CodeFormatAvailableCharHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcountAllowedCharsInFirstPosition(CodeGenerator generator)longcountCombinationsForGenerator(CodeGenerator generator)Calculate the number of combinations for the passed in generator object.longcountCombinationsForGenerator(CodeGenerator generator, int skipCount, boolean firstOnly)Calculate the number of combinations for the passed in generator object.StringgetAvailableCharactersForFormatElement(CodeGenerator generator, char formatElement)protected Map<Character,String>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 Detail
-
CODE_FRIENDLY_NUMBERS
public static final String CODE_FRIENDLY_NUMBERS
- See Also:
- Constant Field Values
-
CODE_FRIENDLY_LETTERS
public static final String CODE_FRIENDLY_LETTERS
- See Also:
- Constant Field Values
-
CODE_FRIENDLY_ALL
public static final String CODE_FRIENDLY_ALL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAvailableCharactersForFormatElement
public String getAvailableCharactersForFormatElement(CodeGenerator generator, char formatElement)
-
countCombinationsForGenerator
public long countCombinationsForGenerator(CodeGenerator generator)
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
protected Map<Character,String> 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.- Parameters:
generator- The CodeGenerator- Returns:
- The character map to use for the alphabet
-
countAllowedCharsInFirstPosition
public long countAllowedCharsInFirstPosition(CodeGenerator generator)
-
-