asCardBrand static method
Converts an unchecked String value to a {@link CardBrand} or {@code null}.
@param possibleCardType a String that might match a {@link CardBrand} or be empty. @return {@code null} if the input is blank, else the appropriate {@link CardBrand}.
Implementation
static CardBrand? asCardBrand(CardBrand? possibleCardType) {
if (possibleCardType == null) {
return null;
}
if (CardBrand.amex == possibleCardType) {
return CardBrand.amex;
} else if (CardBrand.mastercard == possibleCardType) {
return CardBrand.mastercard;
} else if (CardBrand.diners == possibleCardType) {
return CardBrand.diners;
} else if (CardBrand.discover == possibleCardType) {
return CardBrand.discover;
} else if (CardBrand.jcb == possibleCardType) {
return CardBrand.jcb;
} else if (CardBrand.visa == possibleCardType) {
return CardBrand.visa;
} else if (CardBrand.unionpay == possibleCardType) {
return CardBrand.unionpay;
} else {
return CardBrand.unknown;
}
}