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 String
CODE_FRIENDLY_ALL
static String
CODE_FRIENDLY_LETTERS
static String
CODE_FRIENDLY_NUMBERS
-
Constructor Summary
Constructors Constructor Description CodeFormatAvailableCharHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
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.String
getAvailableCharactersForFormatElement(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)
-
-