Class DefaultCouponCodeClearTextGenerationStrategy
java.lang.Object
de.hybris.platform.couponservices.couponcodegeneration.impl.AbstractCouponCodeGenerationStrategy
de.hybris.platform.couponservices.couponcodegeneration.impl.DefaultCouponCodeClearTextGenerationStrategy
- All Implemented Interfaces:
CouponCodeClearTextGenerationStrategy,org.springframework.beans.factory.InitializingBean
public class DefaultCouponCodeClearTextGenerationStrategy
extends AbstractCouponCodeGenerationStrategy
implements CouponCodeClearTextGenerationStrategy, org.springframework.beans.factory.InitializingBean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidcheckLength(int length) checks that the given length is supported by this strategy (only values 2,4,6,8 are valid)protected voidcheckMaximumCouponCodesGenerated(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.generateClearText(MultiCodeCouponModel coupon, int length) returns the generated clear-text part of the coupon code with the given lengthprotected int[]longgetCouponCodeNumberForClearText(MultiCodeCouponModel coupon, String clearText) returns the original coupon code number the given clearText was based on.protected int[]voidsetBitshifts(List<Integer> bitshiftsList) defines how many bits to shift for each two characters that are created from the seed (theMultiCodeCouponModel.couponCodeNumber) (default values are 0, 8, 16, 24, 32, 40, 48, 56)voidsetOffsets(List<Integer> offsetsList) defines the offset which is added when picking a character from the alphabet.Methods inherited from class de.hybris.platform.couponservices.couponcodegeneration.impl.AbstractCouponCodeGenerationStrategy
createIntFromTwoCharactersString, createTwoCharactersFromByte, pickCharacter, pickInt
-
Constructor Details
-
DefaultCouponCodeClearTextGenerationStrategy
public DefaultCouponCodeClearTextGenerationStrategy()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
generateClearText
Description copied from interface:CouponCodeClearTextGenerationStrategyreturns the generated clear-text part of the coupon code with the given length- Specified by:
generateClearTextin interfaceCouponCodeClearTextGenerationStrategy
-
getCouponCodeNumberForClearText
Description copied from interface:CouponCodeClearTextGenerationStrategyreturns the original coupon code number the given clearText was based on. (This is the inverse function to theCouponCodeClearTextGenerationStrategy.generateClearText(MultiCodeCouponModel, int)method)- Specified by:
getCouponCodeNumberForClearTextin interfaceCouponCodeClearTextGenerationStrategy
-
checkMaximumCouponCodesGenerated
Checks if the given coupon's couponCodeNumber has exceeded the maximum number of coupon codes that can be generated for the given 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
-
getBitshifts
protected int[] getBitshifts() -
setBitshifts
defines how many bits to shift for each two characters that are created from the seed (theMultiCodeCouponModel.couponCodeNumber) (default values are 0, 8, 16, 24, 32, 40, 48, 56) -
getOffsets
protected int[] getOffsets() -
setOffsets
defines the offset which is added when picking a character from the alphabet. (The default values are 3, 5, 7, 11, 13, 17, 19, 23, meaning that for the first two characters (i.e. one byte) the offset is 3. -
checkLength
protected void checkLength(int length) checks that the given length is supported by this strategy (only values 2,4,6,8 are valid)
-