fix: jdk 11 > 1.8 사용으로 String.repeat 함수 대체

main
Jonguk. Lim 2 years ago
parent e8a72f4d53
commit d648f7741b

@ -4,6 +4,8 @@ import java.util.Arrays;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
public class Masking { public class Masking {
final static String MASKING_STAR = "*"; final static String MASKING_STAR = "*";
final static char CHAR_STAR = '*'; final static char CHAR_STAR = '*';
@ -48,13 +50,13 @@ public class Masking {
Pattern pattern = Pattern.compile(NAME_MASKING_EN); Pattern pattern = Pattern.compile(NAME_MASKING_EN);
Matcher m = pattern.matcher(name); Matcher m = pattern.matcher(name);
if(m.find()) return name.replaceFirst(NAME_MASKING_EN, MASKING_STAR.repeat(m.group().length())); //if(m.find()) return name.replaceFirst(NAME_MASKING_EN, MASKING_STAR.repeat(m.group().length()));
//if(m.find()) return name.replaceFirst(NAME_MASKING_EN, StringUtils.repeat(MASKING_STAR, m.group().length())); if(m.find()) return name.replaceFirst(NAME_MASKING_EN, StringUtils.repeat(MASKING_STAR, m.group().length()));
} }
// 한글인 경우 // 한글인 경우
return name.replaceFirst(NAME_MASKING_KO, MASKING_STAR.repeat(name.length() - 2)); //return name.replaceFirst(NAME_MASKING_KO, MASKING_STAR.repeat(name.length() - 2));
//return name.replaceFirst(NAME_MASKING_KO, StringUtils.repeat(MASKING_STAR, name.length() - 2)); return name.replaceFirst(NAME_MASKING_KO, StringUtils.repeat(MASKING_STAR, name.length() - 2));
} }
/** /**
@ -64,7 +66,8 @@ public class Masking {
*/ */
public static String maskingRn(String regNumber) { public static String maskingRn(String regNumber) {
return regNumber.replaceAll("([0-9]{6})-([1-4]{1})([0-9]{6})", "$1-$2".concat(MASKING_STAR.repeat(6))); //return regNumber.replaceAll("([0-9]{6})-([1-4]{1})([0-9]{6})", "$1-$2".concat(MASKING_STAR.repeat(6)));
return regNumber.replaceAll("([0-9]{6})-([1-4]{1})([0-9]{6})", "$1-$2".concat(StringUtils.repeat(MASKING_STAR,6)));
} }
/** /**
@ -94,7 +97,7 @@ public class Masking {
* @return * @return
*/ */
public static String maskingMail(String email) { public static String maskingMail(String email) {
return email.replaceAll("[A-z|0-9|.-]+@", MASKING_STAR.repeat(5).concat("@")); return email.replaceAll("[A-z|0-9|.-]+@", StringUtils.repeat(MASKING_STAR,5).concat("@"));
} }

Loading…
Cancel
Save