!667 【6.x】泛型修复

Merge pull request !667 from 阿超/v6-dev
This commit is contained in:
Looly 2022-06-28 11:01:24 +00:00 committed by Gitee
commit f8238c3212
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 2 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);
}