public class DefaultCouponCodeClearTextGenerationStrategy extends AbstractCouponCodeGenerationStrategy implements CouponCodeClearTextGenerationStrategy
| Constructor and Description |
|---|
DefaultCouponCodeClearTextGenerationStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
checkLength(int length)
checks that the given length is supported by this strategy (only values 2,4,6,8 are valid)
|
protected void |
checkMaximumCouponCodesGenerated(MultiCodeCouponModel coupon,
int length)
Checks if the given coupon's couponCodeNumber has exceeded the maximum number of coupon codes that can be
generated for the given length.
|
java.lang.String |
generateClearText(MultiCodeCouponModel coupon,
int length)
returns the generated clear-text part of the coupon code with the given length
|
protected int[] |
getBitshifts() |
long |
getCouponCodeNumberForClearText(MultiCodeCouponModel coupon,
java.lang.String clearText)
returns the original coupon code number the given clearText was based on.
|
protected int[] |
getOffsets() |
void |
setBitshifts(java.util.List<java.lang.Integer> bitshiftsList)
defines how many bits to shift for each two characters that are created from the seed (the
MultiCodeCouponModel.couponCodeNumber) (default values are 0, 8, 16, 24, 32, 40, 48, 56) |
void |
setOffsets(java.util.List<java.lang.Integer> offsetsList)
defines the offset which is added when picking a character from the alphabet.
|
createIntFromTwoCharactersString, createTwoCharactersFromByte, pickCharacter, pickIntpublic DefaultCouponCodeClearTextGenerationStrategy()
public void afterPropertiesSet()
public java.lang.String generateClearText(MultiCodeCouponModel coupon, int length)
CouponCodeClearTextGenerationStrategygenerateClearText in interface CouponCodeClearTextGenerationStrategypublic long getCouponCodeNumberForClearText(MultiCodeCouponModel coupon, java.lang.String clearText)
CouponCodeClearTextGenerationStrategyCouponCodeClearTextGenerationStrategy.generateClearText(MultiCodeCouponModel, int) method)getCouponCodeNumberForClearText in interface CouponCodeClearTextGenerationStrategyprotected void checkMaximumCouponCodesGenerated(MultiCodeCouponModel coupon, int length)
The maximum number of coupon codes are: length 2 2^8 = 256 coupons length 4 2^16 = 65.536 coupons length 6 2^24 = 16.777.216 coupons length 7 2^32 = 4.294.967.296 coupons
protected int[] getBitshifts()
public void setBitshifts(java.util.List<java.lang.Integer> bitshiftsList)
MultiCodeCouponModel.couponCodeNumber) (default values are 0, 8, 16, 24, 32, 40, 48, 56)protected int[] getOffsets()
public void setOffsets(java.util.List<java.lang.Integer> offsetsList)
protected void checkLength(int length)
Copyright © 2018 SAP SE. All Rights Reserved.