mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
change to wrapAllWithPair
This commit is contained in:
parent
ed4d819ed4
commit
50837bf2f9
@ -17,6 +17,7 @@
|
||||
* 【core 】 增加Ipv4Util(pr#161@Gitee)
|
||||
* 【core 】 增加CalendarUtil和DateUtil增加isSameMonth方法(pr#161@Gitee)
|
||||
* 【core 】 Dict增加of方法(issue#1035@Github)
|
||||
* 【core 】 StrUtil.wrapAll方法不明确修改改为wrapAllWithPair(issue#1042@Github)
|
||||
|
||||
### Bug修复#
|
||||
* 【poi 】 修复ExcelBase.isXlsx方法判断问题(issue#I1S502@Gitee)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user