mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
1.优化of(T)方法, 让其等价于ofNullable(T);
This commit is contained in:
@@ -94,14 +94,14 @@ public class FastStream<T> implements Stream<T>, Iterable<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回包含单个元素的串行流
|
||||
* 返回包含单个元素的串行流, 如果值为null, 则返回空的流, 不抛出异常
|
||||
*
|
||||
* @param t 单个元素
|
||||
* @param <T> 元素类型
|
||||
* @return 包含单个元素的串行流
|
||||
*/
|
||||
public static <T> FastStream<T> of(T t) {
|
||||
return new FastStream<>(Stream.of(t));
|
||||
return Opt.ofNullable(t).map(Stream::of).map(FastStream::new).orElseGet(FastStream::empty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user