package org.codelogger.utils;

import static org.codelogger.utils.StringUtils.isEmpty;

public class VerifyUtils {

    private static final String MOBILE_NUMBER_PATTERN = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";

    private static final String MAIL_PATTERN = "^([a-zA-Z0-9]+[-_\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[-_]?)+[a-zA-Z0-9]+(\\.[a-zA-Z]{2,4})(\\.[a-zA-Z]{2})?$";

    private static final String IP_PATTERN = "(([0-1]?[0-9]?[0-9]|(2[0-4][0-9]|25[0-5]))\\.){3}([0-1]?[0-9]?[0-9]|(2[0-4][0-9]|25[0-5]))";

    /**
     * Return true if given number is a mobile phone number; false otherwise.
     * 
     * @param mobileNumber
     *            mobile phone number to be tested.
     * @return true if given number is a mobile phone number; false otherwise.
     */
    public static boolean isMobileNumber(final String mobileNumber) {

        if (isEmpty(mobileNumber)) {
            return false;
        }
        return mobileNumber.matches(MOBILE_NUMBER_PATTERN);
    }

    /**
     * Return true if given number is an email address; false otherwise.
     * 
     * @param mailAddress
     *            Email address to be tested.
     * @return true if given number is an email address; false otherwise.
     */
    public static boolean isEmail(final String mailAddress) {

        if (isEmpty(mailAddress)) {
            return false;
        }
        return mailAddress.matches(MAIL_PATTERN);
    }

    /**
     * Return true if given number is a IP address; false otherwise.
     * 
     * @param ipAddress
     *            IP address to be tested.
     * @return true if given number is a IP address; false otherwise.
     */
    public static boolean isIPAddress(final String ipAddress) {

        if (isEmpty(ipAddress)) {
            return false;
        }
        return ipAddress.matches(IP_PATTERN);
    }
}

@@ -109,18 +109,16 @@
 tils %7B%0A%0A
-  
   privat
@@ -169,57 +169,21 @@
 = %22%5E
-((13%5B0-9%5D)%7C(15%5B%5E4,%5C%5CD%5D)%7C(18%5B0,5-9%5D))
+1
 %5C%5Cd%7B
-8
+10
 %7D$%22;%0A%0A
-  
   pr
@@ -333,18 +333,16 @@
 %7D)?$%22;%0A%0A
-  
   privat
@@ -471,26 +471,22 @@
 5%5D))%22;%0A%0A
-  
   /**%0A
-  
    * Ret
@@ -545,34 +545,32 @@
 alse otherwise.%0A
-  
    * %0A     * @pa
@@ -554,34 +554,32 @@
 rwise.%0A   * %0A   
-  
 * @param mobileN
@@ -583,34 +583,16 @@
 leNumber
-%0A     *           
  mobile 
@@ -610,34 +610,32 @@
 r to be tested.%0A
-  
    * @return tru
@@ -694,33 +694,29 @@
 herwise.%0A   
-  
 */%0A  
- 
- 
 public stati
@@ -766,28 +766,24 @@
 eNumber) %7B%0A%0A
-    
     if (isEm
@@ -799,30 +799,24 @@
 eNumber)) %7B%0A
-      
       return
@@ -823,34 +823,26 @@
  false;%0A    
-  
-  %7D%0A    
+%7D%0A
     return m
@@ -885,33 +885,27 @@
 TTERN);%0A
-  
   %7D%0A%0A  
- 
- 
 /**%0A
-  
    * Ret
@@ -962,39 +962,35 @@
 e otherwise.%0A   
-  
 * %0A
-  
    * @param mail
@@ -996,34 +996,16 @@
 lAddress
-%0A     *           
  Email a
@@ -1017,34 +1017,32 @@
 s to be tested.%0A
-  
    * @return tru
@@ -1092,39 +1092,35 @@
 e otherwise.%0A   
- 
- 
 */%0A
-  
   public static 
@@ -1156,36 +1156,32 @@
 mailAddress) %7B%0A%0A
-    
     if (isEmpty(
@@ -1188,38 +1188,32 @@
 mailAddress)) %7B%0A
-      
       return fal
@@ -1216,34 +1216,26 @@
  false;%0A    
-    %7D%0A    
+%7D%0A
     return m
@@ -1272,17 +1272,13 @@
 N);%0A
-  
   %7D%0A%0A
-  
   /*
@@ -1282,18 +1282,16 @@
  /**%0A   
-  
 * Return
@@ -1349,23 +1349,19 @@
 ise.%0A   
-  
 * %0A
-  
    * @pa
@@ -1377,26 +1377,8 @@
 ress
-%0A     *           
  IP 
@@ -1402,18 +1402,16 @@
 ted.%0A   
- 
- 
 * @retur
@@ -1474,17 +1474,13 @@
 %0A   
-  
 */%0A  
- 
- 
 publ
@@ -1540,20 +1540,16 @@
  %7B%0A%0A    
-  
-  
 if (isEm
@@ -1572,22 +1572,16 @@
 %7B%0A      
-    
-  
 return f
@@ -1590,26 +1590,18 @@
 se;%0A    
-    %7D%0A    
+%7D%0A
     retu
@@ -1634,16 +1634,14 @@
 TTERN);%0A
-  
   %7D%0A%7D%0A

update VerifyUtils