<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-d7e2a68c7c.css">
<div class="htmledit_views" id="content_views">
用於驗證的請求接口:
返回:
{"bank":"CCB","validated":true,"cardType":"DC","key":"6217002430035835629","messages":[],"stat":"ok"}bank 銀行的 英文簡稱
validated 是否通過驗證
下面貼個工具類: 使用此工具類可實現鏈式調用 不要忘記先調用getInstance方法
/** * @Author Xi * Created by zz.wbkj.xi on 2016/11/2. */
public class CardUtils {<span style="color:#000080;"><strong>public static </strong></span>Map<String,String> <span style="color:#660e7a;"><em>bankName </em></span>= <span style="color:#000080;"><strong>new </strong></span>HashMap<>(); <span style="color:#000080;"><strong>private </strong></span>CardUtils(){ <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"ICBC"</strong></span>,<span style="color:#008000;"><strong>"中國工商銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"BOC"</strong></span>,<span style="color:#008000;"><strong>"中國銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CCB"</strong></span>,<span style="color:#008000;"><strong>"中國建設銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"ABC"</strong></span>,<span style="color:#008000;"><strong>"中國農業銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"HNRCU"</strong></span>,<span style="color:#008000;"><strong>"河南省農村信用社"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"PSBC"</strong></span>,<span style="color:#008000;"><strong>"中國郵政儲蓄銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CEB"</strong></span>,<span style="color:#008000;"><strong>"中國光大銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"BCM"</strong></span>,<span style="color:#008000;"><strong>"交通銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CMB"</strong></span>,<span style="color:#008000;"><strong>"招商銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CMBC"</strong></span>,<span style="color:#008000;"><strong>"民生銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CDB"</strong></span>,<span style="color:#008000;"><strong>"國家開發銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"CIB"</strong></span>,<span style="color:#008000;"><strong>"興業銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"BCCB"</strong></span>,<span style="color:#008000;"><strong>"北京市商業銀行"</strong></span>); <span style="color:#660e7a;"><em>bankName</em></span>.put(<span style="color:#008000;"><strong>"HSBC"</strong></span>,<span style="color:#008000;"><strong>"匯豐銀行"</strong></span>); } <span style="color:#000080;"><strong>private static class </strong></span>CardUtilsHolder{ <span style="color:#000080;"><strong>private static </strong></span>CardUtils <span style="color:#660e7a;"><em>holder </em></span>= <span style="color:#000080;"><strong>new </strong></span>CardUtils() ; } <span style="color:#000080;"><strong>public static </strong></span>CardUtils getInstance(){ <span style="color:#000080;"><strong>return </strong></span>CardUtilsHolder.<span style="color:#660e7a;"><em>holder</em></span>; } <span style="color:#000080;"><strong>public static </strong></span>String isBank(String bankStr){ <span style="color:#000080;"><strong>if </strong></span>(<span style="color:#660e7a;"><em>bankName</em></span>.containsKey(bankStr)){ Log.<span style="font-style:italic;">e</span>(<span style="color:#008000;"><strong>"包含"</strong></span>,bankStr); <span style="color:#000080;"><strong>return </strong></span><span style="color:#660e7a;"><em>bankName</em></span>.get(bankStr); } Log.<span style="font-style:italic;">e</span>(<span style="color:#008000;"><strong>"不包含"</strong></span>,bankStr); <span style="color:#000080;"><strong>return </strong></span><span style="color:#008000;"><strong>""</strong></span>; }
}
使用方法:
String bankName = CardUtils.getInstance().isBank(bankResultBean.getBank());可對bankName進行 TextUtils.isEmpty()方法進行判空