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 Details

    • DefaultCouponCodeClearTextGenerationStrategy

      public DefaultCouponCodeClearTextGenerationStrategy()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • generateClearText

      public String generateClearText(MultiCodeCouponModel coupon, int length)
      Description copied from interface: CouponCodeClearTextGenerationStrategy
      returns the generated clear-text part of the coupon code with the given length
      Specified by:
      generateClearText in interface CouponCodeClearTextGenerationStrategy
    • getCouponCodeNumberForClearText

      public long getCouponCodeNumberForClearText(MultiCodeCouponModel coupon, String clearText)
      Description copied from interface: CouponCodeClearTextGenerationStrategy
      returns the original coupon code number the given clearText was based on. (This is the inverse function to the CouponCodeClearTextGenerationStrategy.generateClearText(MultiCodeCouponModel, int) method)
      Specified by:
      getCouponCodeNumberForClearText in interface CouponCodeClearTextGenerationStrategy
    • 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(List<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)
    • getOffsets

      protected int[] getOffsets()
    • setOffsets

      public void setOffsets(List<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)