@Test public void getBrand_with_a_null_number_fails() { this.expectedEx.expect(IllegalArgumentException.class); CreditCard4J.getBrand(null); }
public static CardBrand getBrand(String cardNumber) { checkNotNull("Invalid card number", cardNumber); String number = CardNumberCleaner.clean(cardNumber); for (CardBrand type : CardBrand.values()) { for (String prefix : type.getPrefixes()) { if (number.startsWith(prefix)) { return type; } } } return CardBrand.UNKNOWN; }
CreditCard4J { public static CardBrand getBrand(String cardNumber) { checkNotNull("Invalid card number", cardNumber); String number = CardNumberCleaner.clean(cardNumber); for (CardBrand type : CardBrand.values()) { for (String prefix : type.getPrefixes()) { if (number.startsWith(prefix)) { return type; } } } return CardBrand.UNKNOWN; } }
CreditCard4J { public static CardBrand getBrand(String cardNumber) { checkNotNull("Invalid card number", cardNumber); String number = CardNumberCleaner.clean(cardNumber); for (CardBrand type : CardBrand.values()) { for (String prefix : type.getPrefixes()) { if (number.startsWith(prefix)) { return type; } } } return CardBrand.UNKNOWN; }  }
CreditCard4J { public static CardBrand getBrand(String cardNumber) { checkNotNull("Invalid card number", cardNumber); String number = CardNumberCleaner.clean(cardNumber); for (CardBrand type : CardBrand.values()) { for (String prefix : type.getPrefixes()) { if (number.startsWith(prefix)) { return type; } } } return CardBrand.UNKNOWN; }  static void resetConfig(); static CardBrand getBrand(String cardNumber); static String validateCardNumber(String cardNumber); static boolean isValidCardNumber(String cardNumber); }
CreditCard4J { public static CardBrand getBrand(String cardNumber) { checkNotNull("Invalid card number", cardNumber); String number = CardNumberCleaner.clean(cardNumber); for (CardBrand type : CardBrand.values()) { for (String prefix : type.getPrefixes()) { if (number.startsWith(prefix)) { return type; } } } return CardBrand.UNKNOWN; }  static void resetConfig(); static CardBrand getBrand(String cardNumber); static String validateCardNumber(String cardNumber); static boolean isValidCardNumber(String cardNumber); static String[] ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS; }