瀏覽代碼

값이 없을 경우 "" 으로 리턴하도록 추가

gagamel 5 年之前
父節點
當前提交
97dbd2be34
共有 1 個文件被更改,包括 17 次插入0 次删除
  1. 17 0
      src/main/java/com/style24/core/support/util/MaskingUtils.java

+ 17 - 0
src/main/java/com/style24/core/support/util/MaskingUtils.java

@@ -4,6 +4,8 @@ import java.util.Arrays;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang3.StringUtils;
+
 import lombok.extern.slf4j.Slf4j;
 
 /**
@@ -26,6 +28,9 @@ public class MaskingUtils {
 	 * @return
 	 */
 	public static String id(String str) {
+		if (StringUtils.isBlank(str))
+			return "";
+
 		String replaceString = str;
 
 		Matcher matcher = Pattern.compile("^(...)(.*)$").matcher(str);
@@ -62,6 +67,9 @@ public class MaskingUtils {
 	 * @return
 	 */
 	public static String name(String str) {
+		if (StringUtils.isBlank(str))
+			return "";
+
 		String regex = "^(.)(.+)(.)$";
 		if (str.length() == 2) {
 			regex = "^(.)(.+)$";
@@ -103,6 +111,9 @@ public class MaskingUtils {
 	 * @return
 	 */
 	public static String phoneNo(String str) {
+		if (StringUtils.isBlank(str))
+			return "";
+
 		Matcher matcher = Pattern.compile("^(\\d{3})-?(\\d{3,4})-?(\\d{4})$").matcher(str);
 
 		if (matcher.find()) {
@@ -124,6 +135,9 @@ public class MaskingUtils {
 	 * @return
 	 */
 	public static String email(String str) {
+		if (StringUtils.isBlank(str))
+			return "";
+
 		Matcher matcher = Pattern.compile("^(...)(.*)([@]{1})(.*)$").matcher(str);
 
 		if (matcher.find()) {
@@ -159,6 +173,9 @@ public class MaskingUtils {
 	 * @return
 	 */
 	public static String all(String str) {
+		if (StringUtils.isBlank(str))
+			return "";
+
 		Matcher matcher = Pattern.compile("^(.*)$").matcher(str);
 
 		if (matcher.find()) {