change to wrapAllWithPair

This commit is contained in:
Looly 2020-08-27 16:38:01 +08:00
parent ed4d819ed4
commit 50837bf2f9
3 changed files with 16 additions and 6 deletions

View File

@ -17,6 +17,7 @@
* 【core 】 增加Ipv4Utilpr#161@Gitee
* 【core 】 增加CalendarUtil和DateUtil增加isSameMonth方法pr#161@Gitee
* 【core 】 Dict增加of方法issue#1035@Github
* 【core 】 StrUtil.wrapAll方法不明确修改改为wrapAllWithPairissue#1042@Github
### Bug修复#
* 【poi 】 修复ExcelBase.isXlsx方法判断问题issue#I1S502@Gitee

View File

@ -2731,14 +2731,14 @@ public class StrUtil {
}
/**
* 包装多个字符串
* 使用单个字符包装多个字符串
*
* @param prefixAndSuffix 前缀和后缀
* @param strs 多个字符串
* @return 包装的字符串数组
* @since 4.0.7
* @since 5.4.1
*/
public static String[] wrapAll(CharSequence prefixAndSuffix, CharSequence... strs) {
public static String[] wrapAllWithPair(CharSequence prefixAndSuffix, CharSequence... strs) {
return wrapAll(prefixAndSuffix, prefixAndSuffix, strs);
}
@ -2792,14 +2792,14 @@ public class StrUtil {
}
/**
* 包装多个字符串如果已经包装则不再包装
* 使用成对的字符包装多个字符串如果已经包装则不再包装
*
* @param prefixAndSuffix 前缀和后缀
* @param strs 多个字符串
* @return 包装的字符串数组
* @since 4.0.7
* @since 5.4.1
*/
public static String[] wrapAllIfMissing(CharSequence prefixAndSuffix, CharSequence... strs) {
public static String[] wrapAllWithPairIfMissing(CharSequence prefixAndSuffix, CharSequence... strs) {
return wrapAllIfMissing(prefixAndSuffix, prefixAndSuffix, strs);
}

View File

@ -458,4 +458,13 @@ public class StrUtilTest {
String cleanBlank = StrUtil.filter(" 你 好 ", c -> !CharUtil.isBlankChar(c));
Assert.assertEquals("你好", cleanBlank);
}
@Test
public void wrapAllTest(){
String[] strings = StrUtil.wrapAll("`", "`", StrUtil.splitToArray("1,2,3,4", ','));
Assert.assertEquals("[`1`, `2`, `3`, `4`]", StrUtil.utf8Str(strings));
strings = StrUtil.wrapAllWithPair("`", StrUtil.splitToArray("1,2,3,4", ','));
Assert.assertEquals("[`1`, `2`, `3`, `4`]", StrUtil.utf8Str(strings));
}
}