Serializable, Comparable<CardBrand>public enum CardBrand extends Enum<CardBrand>
| Enum Constant | Description |
|---|---|
AMERICAN_EXPRESS |
|
DINERS_CLUB |
|
DISCOVER |
|
EMPTY |
|
JCB |
|
MAESTRO |
|
MASTERCARD |
|
UNIONPAY |
|
UNKNOWN |
|
VISA |
| Modifier and Type | Method | Description |
|---|---|---|
static CardBrand |
forBrandName(String brandName) |
|
static CardBrand |
forCardNumber(String cardNumber) |
Returns the card type matching this account, or UNKNOWN
for no match.
|
String |
getBrandName() |
|
int |
getMaxCardLength() |
|
int |
getMinCardLength() |
|
Pattern |
getPattern() |
|
int |
getSecurityCodeLength() |
|
int[] |
getSpaceIndices() |
|
static boolean |
isLuhnValid(String cardNumber) |
Performs the Luhn check on the given card number.
|
boolean |
validate(String cardNumber) |
|
static CardBrand |
valueOf(String name) |
Returns the enum constant of this type with the specified name.
|
static CardBrand[] |
values() |
Returns an array containing the constants of this enum type, in
the order they are declared.
|
@SerializedName("visa")
public static final CardBrand VISA
@SerializedName("mastercard")
public static final CardBrand MASTERCARD
@SerializedName("discover")
public static final CardBrand DISCOVER
@SerializedName("american_express")
public static final CardBrand AMERICAN_EXPRESS
@SerializedName("diners_club")
public static final CardBrand DINERS_CLUB
@SerializedName("jcb")
public static final CardBrand JCB
@SerializedName("maestro")
public static final CardBrand MAESTRO
@SerializedName("unionpay")
public static final CardBrand UNIONPAY
@SerializedName("unknown")
public static final CardBrand UNKNOWN
@SerializedName("empty")
public static final CardBrand EMPTY
public static CardBrand[] values()
for (CardBrand c : CardBrand.values()) System.out.println(c);
public static CardBrand valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static CardBrand forCardNumber(String cardNumber)
public Pattern getPattern()
public int getSecurityCodeLength()
public int getMinCardLength()
public int getMaxCardLength()
public String getBrandName()
public int[] getSpaceIndices()
public static boolean isLuhnValid(String cardNumber)
cardNumber - a String consisting of numeric digits (only).true if the sequence passes the checksumIllegalArgumentException - if cardNumber contained a non-digit (where Character.isDefined(char) is false).public boolean validate(String cardNumber)
cardNumber - The card number to validate.true if this card number is locally valid.Copyright © 2018 The Apache Software Foundation. All rights reserved.