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 Constructor Description DefaultCouponCodeClearTextGenerationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected 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.java.lang.StringgenerateClearText(MultiCodeCouponModel coupon, int length)returns the generated clear-text part of the coupon code with the given lengthprotected int[]getBitshifts()longgetCouponCodeNumberForClearText(MultiCodeCouponModel coupon, java.lang.String clearText)returns the original coupon code number the given clearText was based on.protected int[]getOffsets()voidsetBitshifts(java.util.List<java.lang.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(java.util.List<java.lang.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
-
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
generateClearText
public java.lang.String generateClearText(MultiCodeCouponModel coupon, int length)
Description copied from interface:CouponCodeClearTextGenerationStrategyreturns the generated clear-text part of the coupon code with the given length- Specified by:
generateClearTextin interfaceCouponCodeClearTextGenerationStrategy
-
getCouponCodeNumberForClearText
public long getCouponCodeNumberForClearText(MultiCodeCouponModel coupon, java.lang.String clearText)
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
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.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
public 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 (theMultiCodeCouponModel.couponCodeNumber) (default values are 0, 8, 16, 24, 32, 40, 48, 56)
-
getOffsets
protected int[] getOffsets()
-
setOffsets
public void setOffsets(java.util.List<java.lang.Integer> offsetsList)
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)
-
-