Browse Source

字符串工具类

master
richie 5 years ago
parent
commit
32df7328cb
  1. 9
      src/main/java/com/fanruan/api/util/ArrayKit.java
  2. 2
      src/main/java/com/fanruan/api/util/GeneralKit.java
  3. 89
      src/main/java/com/fanruan/api/util/StringKit.java
  4. 4
      src/test/java/com/fanruan/api/util/GeneralKitTest.java

9
src/main/java/com/fanruan/api/util/ArrayKit.java

@ -0,0 +1,9 @@
package com.fanruan.api.util;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-16
*/
public class ArrayKit {
}

2
src/main/java/com/fanruan/api/util/GeneralUtils.java → src/main/java/com/fanruan/api/util/GeneralKit.java

@ -7,7 +7,7 @@ import java.io.IOException;
* @version 10.0 * @version 10.0
* Created by richie on 2019-08-09 * Created by richie on 2019-08-09
*/ */
public class GeneralUtils { public class GeneralKit {
/** /**
* 返回系统的首选MAC地址 * 返回系统的首选MAC地址

89
src/main/java/com/fanruan/api/util/StringKit.java

@ -0,0 +1,89 @@
package com.fanruan.api.util;
import com.fr.stable.StringUtils;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-16
* 字符串工具类
*/
public class StringKit {
public static final String EMPTY = "";
public static final String BLANK = " ";
/**
* <p>检查一个字符串是否是空字符串</p>
* <p/>
* <pre>
* StringKit.isEmpty(null) = true
* StringKit.isEmpty("") = true
* StringKit.isEmpty(" ") = false
* StringKit.isEmpty("bob") = false
* StringKit.isEmpty(" bob ") = false
* </pre>
* <p/>
*
* @param text 被检查的字符串可能为null
* @return 如果字符串为空或者是null则返回true否则返回false
*/
public static boolean isEmpty(String text) {
return StringUtils.isEmpty(text);
}
/**
* <p>检查一个字符串是否不为空字符串</p>
* <p/>
* <pre>
* StringKit.isNotEmpty(null) = false
* StringKit.isNotEmpty("") = false
* StringKit.isNotEmpty(" ") = true
* StringKit.isNotEmpty("bob") = true
* StringKit.isNotEmpty(" bob ") = true
* </pre>
*
* @param text 被检查的字符串可能是null
* @return 如果字符串不为空且不是null则返回true否则返回false
*/
public static boolean isNotEmpty(String text) {
return StringUtils.isNotEmpty(text);
}
/**
* <p>检查一个字符串是否为空白字符串</p>
* <p/>
* <pre>
* StringKit.isBlank(null) = true
* StringKit.isBlank("") = true
* StringKit.isBlank(" ") = true
* StringKit.isBlank("bob") = false
* StringKit.isBlank(" bob ") = false
* </pre>
*
* @param text 被检查的字符串
* @return 如果字符串为空空格符或者null那么返回true否则返回false
*/
public static boolean isBlank(String text) {
return StringUtils.isBlank(text);
}
/**
* <p>检查一个字符串是否不是空白字符串</p>
* <p/>
* <pre>
* StringKit.isNotBlank(null) = false
* StringKit.isNotBlank("") = false
* StringKit.isNotBlank(" ") = false
* StringKit.isNotBlank("bob") = true
* StringKit.isNotBlank(" bob ") = true
* </pre>
*
* @param text 被检查的字符串
* @return 如果字符串不是空字符串空格符以及null那么就返回true否则返回false
*/
public static boolean isNotBlank(String text) {
return StringUtils.isNotBlank(text);
}
}

4
src/test/java/com/fanruan/api/util/GeneralUtilsTest.java → src/test/java/com/fanruan/api/util/GeneralKitTest.java

@ -9,10 +9,10 @@ import org.junit.Test;
* @version 10.0 * @version 10.0
* Created by richie on 2019-08-09 * Created by richie on 2019-08-09
*/ */
public class GeneralUtilsTest extends Prepare { public class GeneralKitTest extends Prepare {
@Test @Test
public void getMacAddress() throws Exception{ public void getMacAddress() throws Exception{
Assert.assertEquals(GeneralUtils.getMacAddress(), com.fr.general.GeneralUtils.getMacAddress()); Assert.assertEquals(GeneralKit.getMacAddress(), com.fr.general.GeneralUtils.getMacAddress());
} }
} }
Loading…
Cancel
Save