|
|
@@ -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()) {
|