Caratacus 8 năm trước cách đây
mục cha
commit
af3468d497

+ 1 - 3
README.md

@@ -48,9 +48,6 @@ Mybatis 增强工具包 - 只做增强不做改变,简化`CRUD`操作
 
 [SSM-实战 Demo](http://git.oschina.net/juapk/SpringWind)
 
-     `如果你喜欢Hibernate,可以尝试使用`
-[Hibernate-Plus](http://git.oschina.net/baomidou/hibernate-plus)
-
 # 下载地址 | Download
 
 [点此去下载](http://maven.aliyun.com/nexus/#nexus-search;quick~mybatis-plus)
@@ -71,6 +68,7 @@ Mybatis 增强工具包 - 只做增强不做改变,简化`CRUD`操作
 
 - [基于Cookie的SSO中间件 Kisso](http://git.oschina.net/baomidou/kisso)
 - [Java快速开发框架 SpringWind](http://git.oschina.net/juapk/SpringWind)
+- [基于Hibernate扩展 Hibernate-Plus](http://git.oschina.net/baomidou/hibernate-plus)
 
 # 期望 | Futures
 

+ 98 - 79
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/StringUtils.java

@@ -29,7 +29,10 @@ import java.util.regex.Pattern;
  * @Date 2016-08-18
  */
 public class StringUtils {
-	
+
+	/**
+	 * 空字符
+	 */
 	public static final String EMPTY = "";
 
 	/**
@@ -37,10 +40,6 @@ public class StringUtils {
 	 */
 	public static final char UNDERLINE = '_';
 
-	/**
-	 * 空字符串
-	 */
-	public static final String EMPTY_STRING = "";
 	/**
 	 * 占位符
 	 */
@@ -92,7 +91,7 @@ public class StringUtils {
 	 */
 	public static String camelToUnderline(String param) {
 		if (isEmpty(param)) {
-			return EMPTY_STRING;
+			return EMPTY;
 		}
 		int len = param.length();
 		StringBuilder sb = new StringBuilder(len);
@@ -117,7 +116,7 @@ public class StringUtils {
 	 */
 	public static String underlineToCamel(String param) {
 		if (isEmpty(param)) {
-			return EMPTY_STRING;
+			return EMPTY;
 		}
 		int len = param.length();
 		StringBuilder sb = new StringBuilder(len);
@@ -263,7 +262,7 @@ public class StringUtils {
 	 */
 	public static String concatCapitalize(String concatStr, final String str) {
 		if (isEmpty(concatStr)) {
-			concatStr = EMPTY_STRING;
+			concatStr = EMPTY;
 		}
 		int strLen;
 		if (str == null || (strLen = str.length()) == 0) {
@@ -306,6 +305,7 @@ public class StringUtils {
 		}
 		return object == null ? false : true;
 	}
+
 	/**
 	 * <p>
 	 * 判断对象是否为空
@@ -318,79 +318,98 @@ public class StringUtils {
 		return !checkValNotNull(object);
 	}
 
-    // endsWith
-    //-----------------------------------------------------------------------
+	// endsWith
+	// -----------------------------------------------------------------------
 
-    /**
-     * <p>Check if a String ends with a specified suffix.</p>
-     *
-     * <p><code>null</code>s are handled without exceptions. Two <code>null</code>
-     * references are considered to be equal. The comparison is case sensitive.</p>
-     *
-     * <pre>
-     * StringUtils.endsWith(null, null)      = true
-     * StringUtils.endsWith(null, "abcdef")  = false
-     * StringUtils.endsWith("def", null)     = false
-     * StringUtils.endsWith("def", "abcdef") = true
-     * StringUtils.endsWith("def", "ABCDEF") = false
-     * </pre>
-     *
-     * @see java.lang.String#endsWith(String)
-     * @param str  the String to check, may be null
-     * @param suffix the suffix to find, may be null
-     * @return <code>true</code> if the String ends with the suffix, case sensitive, or
-     *  both <code>null</code>
-     * @since 2.4
-     */
-    public static boolean endsWith(String str, String suffix) {
-        return endsWith(str, suffix, false);
-    }
+	/**
+	 * <p>
+	 * Check if a String ends with a specified suffix.
+	 * </p>
+	 *
+	 * <p>
+	 * <code>null</code>s are handled without exceptions. Two <code>null</code>
+	 * references are considered to be equal. The comparison is case sensitive.
+	 * </p>
+	 *
+	 * <pre>
+	 * StringUtils.endsWith(null, null)      = true
+	 * StringUtils.endsWith(null, "abcdef")  = false
+	 * StringUtils.endsWith("def", null)     = false
+	 * StringUtils.endsWith("def", "abcdef") = true
+	 * StringUtils.endsWith("def", "ABCDEF") = false
+	 * </pre>
+	 *
+	 * @see java.lang.String#endsWith(String)
+	 * @param str
+	 *            the String to check, may be null
+	 * @param suffix
+	 *            the suffix to find, may be null
+	 * @return <code>true</code> if the String ends with the suffix, case
+	 *         sensitive, or both <code>null</code>
+	 * @since 2.4
+	 */
+	public static boolean endsWith(String str, String suffix) {
+		return endsWith(str, suffix, false);
+	}
 
-    /**
-     * <p>Case insensitive check if a String ends with a specified suffix.</p>
-     *
-     * <p><code>null</code>s are handled without exceptions. Two <code>null</code>
-     * references are considered to be equal. The comparison is case insensitive.</p>
-     *
-     * <pre>
-     * StringUtils.endsWithIgnoreCase(null, null)      = true
-     * StringUtils.endsWithIgnoreCase(null, "abcdef")  = false
-     * StringUtils.endsWithIgnoreCase("def", null)     = false
-     * StringUtils.endsWithIgnoreCase("def", "abcdef") = true
-     * StringUtils.endsWithIgnoreCase("def", "ABCDEF") = false
-     * </pre>
-     *
-     * @see java.lang.String#endsWith(String)
-     * @param str  the String to check, may be null
-     * @param suffix the suffix to find, may be null
-     * @return <code>true</code> if the String ends with the suffix, case insensitive, or
-     *  both <code>null</code>
-     * @since 2.4
-     */
-    public static boolean endsWithIgnoreCase(String str, String suffix) {
-        return endsWith(str, suffix, true);
-    }
+	/**
+	 * <p>
+	 * Case insensitive check if a String ends with a specified suffix.
+	 * </p>
+	 *
+	 * <p>
+	 * <code>null</code>s are handled without exceptions. Two <code>null</code>
+	 * references are considered to be equal. The comparison is case
+	 * insensitive.
+	 * </p>
+	 *
+	 * <pre>
+	 * StringUtils.endsWithIgnoreCase(null, null)      = true
+	 * StringUtils.endsWithIgnoreCase(null, "abcdef")  = false
+	 * StringUtils.endsWithIgnoreCase("def", null)     = false
+	 * StringUtils.endsWithIgnoreCase("def", "abcdef") = true
+	 * StringUtils.endsWithIgnoreCase("def", "ABCDEF") = false
+	 * </pre>
+	 *
+	 * @see java.lang.String#endsWith(String)
+	 * @param str
+	 *            the String to check, may be null
+	 * @param suffix
+	 *            the suffix to find, may be null
+	 * @return <code>true</code> if the String ends with the suffix, case
+	 *         insensitive, or both <code>null</code>
+	 * @since 2.4
+	 */
+	public static boolean endsWithIgnoreCase(String str, String suffix) {
+		return endsWith(str, suffix, true);
+	}
 
-    /**
-     * <p>Check if a String ends with a specified suffix (optionally case insensitive).</p>
-     *
-     * @see java.lang.String#endsWith(String)
-     * @param str  the String to check, may be null
-     * @param suffix the suffix to find, may be null
-     * @param ignoreCase inidicates whether the compare should ignore case
-     *  (case insensitive) or not.
-     * @return <code>true</code> if the String starts with the prefix or
-     *  both <code>null</code>
-     */
-    private static boolean endsWith(String str, String suffix, boolean ignoreCase) {
-        if (str == null || suffix == null) {
-            return (str == null && suffix == null);
-        }
-        if (suffix.length() > str.length()) {
-            return false;
-        }
-        int strOffset = str.length() - suffix.length();
-        return str.regionMatches(ignoreCase, strOffset, suffix, 0, suffix.length());
-    }
+	/**
+	 * <p>
+	 * Check if a String ends with a specified suffix (optionally case
+	 * insensitive).
+	 * </p>
+	 *
+	 * @see java.lang.String#endsWith(String)
+	 * @param str
+	 *            the String to check, may be null
+	 * @param suffix
+	 *            the suffix to find, may be null
+	 * @param ignoreCase
+	 *            inidicates whether the compare should ignore case (case
+	 *            insensitive) or not.
+	 * @return <code>true</code> if the String starts with the prefix or both
+	 *         <code>null</code>
+	 */
+	private static boolean endsWith(String str, String suffix, boolean ignoreCase) {
+		if (str == null || suffix == null) {
+			return (str == null && suffix == null);
+		}
+		if (suffix.length() > str.length()) {
+			return false;
+		}
+		int strOffset = str.length() - suffix.length();
+		return str.regionMatches(ignoreCase, strOffset, suffix, 0, suffix.length());
+	}
 
 }