@Test public void testMask() { NameMask mask = new NameMask(); assertThat(mask.mask(null, null)).isNull(); assertThat(mask.mask("", null)).isEmpty(); assertThat(mask.mask("1", null)).isEqualTo("*"); assertThat(mask.mask("中文", null)).isEqualTo("*文"); assertThat(mask.mask("中文3", null)).isEqualTo("**3"); assertThat(mask.mask("中文四个", null)).isEqualTo("**四个"); }
@Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } if (source.length() <= 3) { return super.mask(source, new int[]{0, 1}); } else { return super.mask(source, new int[]{0, 2}); } }
NameMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } if (source.length() <= 3) { return super.mask(source, new int[]{0, 1}); } else { return super.mask(source, new int[]{0, 2}); } } }
NameMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } if (source.length() <= 3) { return super.mask(source, new int[]{0, 1}); } else { return super.mask(source, new int[]{0, 2}); } }  }
NameMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } if (source.length() <= 3) { return super.mask(source, new int[]{0, 1}); } else { return super.mask(source, new int[]{0, 2}); } }  @Override String mask(String source, int[] params); }
NameMask extends PartMask implements MaskStrategy { @Override public String mask(String source, int[] params) { if (source == null || source.length() == 0) { return source; } if (source.length() <= 3) { return super.mask(source, new int[]{0, 1}); } else { return super.mask(source, new int[]{0, 2}); } }  @Override String mask(String source, int[] params);  }