.code(generateCode()) .effective(new Coupon.Effective("cart", ImmutableList.<Integer>of(), ImmutableList.<Integer>of())) .basketType("both") .startDate(new Date()); builder.discount(new Coupon.Discount("percentage", new BigDecimal(percentageStr), BigDecimal.ZERO)); } catch (NumberFormatException e) { throw new IllegalArgumentException("percentage is not valid (must be a number)"); builder.discount(new Coupon.Discount("value", BigDecimal.ZERO, new BigDecimal(valueStr))); } catch (NumberFormatException e) { throw new IllegalArgumentException("value is not valid (must be a number)"); builder.expire(new Coupon.Expire("timestamp", 0, new Date(System.currentTimeMillis() + ms))); unlimitedRedeem = "0"; try { builder.expire(new Coupon.Expire("limit", Integer.parseInt(limitStr), new Date())); } catch (NumberFormatException e) { throw new IllegalArgumentException("limit is not valid (must be a number)"); builder.expire(new Coupon.Expire("timestamp", 0, new Date(System.currentTimeMillis() + 1))); builder.expireNever(Integer.parseInt(neverExpire)); builder.redeemUnlimited(Integer.parseInt(unlimitedRedeem)); builder.minimum(new BigDecimal(minimumBasket)); } catch (NumberFormatException e) { throw new IllegalArgumentException("min_value is not valid (must be a number)");