@Test void getMaskedString() { assertThat(StringUtils.getMaskedString("1234567890"), is("*****4567890")); assertThat(StringUtils.getMaskedString("1234567890", 1), is("*****0")); assertThat(StringUtils.getMaskedString("1234567890", 2), is("*****90")); assertThat(StringUtils.getMaskedString("12345"), is("12345")); assertThat(StringUtils.getMaskedString("12", 1), is("*****2")); assertThat(StringUtils.getMaskedString(""), is("")); assertThat(StringUtils.getMaskedString(null), is(nullValue())); }
public static String getMaskedString(String secret, int lastSymbolsCount) { if (StringUtils.isBlank(secret) || secret.length() < lastSymbolsCount) {return secret;} return "*****" + secret.substring(secret.length() - lastSymbolsCount); }
StringUtils { public static String getMaskedString(String secret, int lastSymbolsCount) { if (StringUtils.isBlank(secret) || secret.length() < lastSymbolsCount) {return secret;} return "*****" + secret.substring(secret.length() - lastSymbolsCount); } }
StringUtils { public static String getMaskedString(String secret, int lastSymbolsCount) { if (StringUtils.isBlank(secret) || secret.length() < lastSymbolsCount) {return secret;} return "*****" + secret.substring(secret.length() - lastSymbolsCount); } private  StringUtils(); }
StringUtils { public static String getMaskedString(String secret, int lastSymbolsCount) { if (StringUtils.isBlank(secret) || secret.length() < lastSymbolsCount) {return secret;} return "*****" + secret.substring(secret.length() - lastSymbolsCount); } private  StringUtils(); static boolean isBlank(final CharSequence cs); static boolean isNotBlank(final CharSequence cs); static String getMaskedString(String secret, int lastSymbolsCount); static String getMaskedString(String secret); static String defaultIfBlank(String value, String defaultValue); }
StringUtils { public static String getMaskedString(String secret, int lastSymbolsCount) { if (StringUtils.isBlank(secret) || secret.length() < lastSymbolsCount) {return secret;} return "*****" + secret.substring(secret.length() - lastSymbolsCount); } private  StringUtils(); static boolean isBlank(final CharSequence cs); static boolean isNotBlank(final CharSequence cs); static String getMaskedString(String secret, int lastSymbolsCount); static String getMaskedString(String secret); static String defaultIfBlank(String value, String defaultValue);  }