@Test public void cellphoneHide() { Assert.assertEquals("130******58", SensitiveUtils.cellphoneHide("13071835358")); Assert.assertEquals("307****358", SensitiveUtils.cellphoneHide("3071835358")); Assert.assertEquals("07****358", SensitiveUtils.cellphoneHide("071835358")); Assert.assertEquals("8****8", SensitiveUtils.cellphoneHide("835358")); }
public String cellphoneHide(String data) { if (!Strings.hasText(data)) { return data; } String tmp = data.trim(); if (tmp.length() == PHONE_LENGTH) { return customizeHide(tmp, 3, 2, 6); } int notHideNum = tmp.length() - 4; return customizeHide(tmp, notHideNum / 2, notHideNum - notHideNum / 2, 4); }
SensitiveUtils { public String cellphoneHide(String data) { if (!Strings.hasText(data)) { return data; } String tmp = data.trim(); if (tmp.length() == PHONE_LENGTH) { return customizeHide(tmp, 3, 2, 6); } int notHideNum = tmp.length() - 4; return customizeHide(tmp, notHideNum / 2, notHideNum - notHideNum / 2, 4); } }
SensitiveUtils { public String cellphoneHide(String data) { if (!Strings.hasText(data)) { return data; } String tmp = data.trim(); if (tmp.length() == PHONE_LENGTH) { return customizeHide(tmp, 3, 2, 6); } int notHideNum = tmp.length() - 4; return customizeHide(tmp, notHideNum / 2, notHideNum - notHideNum / 2, 4); }  }
SensitiveUtils { public String cellphoneHide(String data) { if (!Strings.hasText(data)) { return data; } String tmp = data.trim(); if (tmp.length() == PHONE_LENGTH) { return customizeHide(tmp, 3, 2, 6); } int notHideNum = tmp.length() - 4; return customizeHide(tmp, notHideNum / 2, notHideNum - notHideNum / 2, 4); }  String nameHide(final String data); String idCardNoHide(String data); String bankCardNoHide(String data); String cellphoneHide(String data); String emailHide(String data); String defaultHide(String data); String customizeHide(String data, int front, int tail, int hidden); }
SensitiveUtils { public String cellphoneHide(String data) { if (!Strings.hasText(data)) { return data; } String tmp = data.trim(); if (tmp.length() == PHONE_LENGTH) { return customizeHide(tmp, 3, 2, 6); } int notHideNum = tmp.length() - 4; return customizeHide(tmp, notHideNum / 2, notHideNum - notHideNum / 2, 4); }  String nameHide(final String data); String idCardNoHide(String data); String bankCardNoHide(String data); String cellphoneHide(String data); String emailHide(String data); String defaultHide(String data); String customizeHide(String data, int front, int tail, int hidden);  }