mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
CharSequence修正为泛型
This commit is contained in:
parent
d6ac2ef4bc
commit
7c5ec4160a
@ -94,7 +94,7 @@ public class Opt<T> {
|
||||
* @param value 传入需要包裹的元素
|
||||
* @return 一个包裹里元素可能为空,或者为空字符串的 {@code Opt}
|
||||
*/
|
||||
public static Opt<CharSequence> ofBlankAble(final CharSequence value) {
|
||||
public static <T extends CharSequence> Opt<T> ofBlankAble(final T value) {
|
||||
return StrUtil.isBlank(value) ? empty() : new Opt<>(value);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class OptTest {
|
||||
@Test
|
||||
public void ofBlankAbleTest() {
|
||||
// ofBlankAble相对于ofNullable考虑了字符串为空串的情况
|
||||
final CharSequence hutool = Opt.ofBlankAble("").orElse("hutool");
|
||||
final String hutool = Opt.ofBlankAble("").orElse("hutool");
|
||||
Assert.assertEquals("hutool", hutool);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user