@Test public void testMask() { EmailMask mask = new EmailMask(); assertThat(mask.mask(null, null)).isNull(); assertThat(mask.mask("", null)).isEmpty(); assertThat(mask.mask("test", null)).isEqualTo("t***"); assertThat(mask.mask("@test", null)).isEqualTo("@****"); assertThat(mask.mask("123@test", null)).isEqualTo("1*3@test"); assertThat(mask.mask("13@test", null)).isEqualTo("1*@test"); assertThat(mask.mask("1@test", null)).isEqualTo("*@test"); }
@Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } int index = source.indexOf("@"); if (index <= 0) { return super.mask(source, new int[]{1, 0}); } return super.mask(source.substring(0, index), new int[]{1}).concat(source.substring(index)); }
EmailMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } int index = source.indexOf("@"); if (index <= 0) { return super.mask(source, new int[]{1, 0}); } return super.mask(source.substring(0, index), new int[]{1}).concat(source.substring(index)); } }
EmailMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } int index = source.indexOf("@"); if (index <= 0) { return super.mask(source, new int[]{1, 0}); } return super.mask(source.substring(0, index), new int[]{1}).concat(source.substring(index)); }  }
EmailMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } int index = source.indexOf("@"); if (index <= 0) { return super.mask(source, new int[]{1, 0}); } return super.mask(source.substring(0, index), new int[]{1}).concat(source.substring(index)); }  @Override String mask(String source, int[] params); }
EmailMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } int index = source.indexOf("@"); if (index <= 0) { return super.mask(source, new int[]{1, 0}); } return super.mask(source.substring(0, index), new int[]{1}).concat(source.substring(index)); }  @Override String mask(String source, int[] params);  }