From 65ea5c206615d0012608f6e9c628daf79f0485b3 Mon Sep 17 00:00:00 2001 From: achao Date: Tue, 2 Aug 2022 09:57:25 +0800 Subject: [PATCH] :trollface: remove private --- .../cn/hutool/core/stream/FastStream.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/stream/FastStream.java b/hutool-core/src/main/java/cn/hutool/core/stream/FastStream.java index 42031f756..07a2e6f43 100644 --- a/hutool-core/src/main/java/cn/hutool/core/stream/FastStream.java +++ b/hutool-core/src/main/java/cn/hutool/core/stream/FastStream.java @@ -8,6 +8,7 @@ import cn.hutool.core.lang.mutable.MutableInt; import cn.hutool.core.lang.mutable.MutableObj; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.StrUtil; +import cn.hutool.core.util.ArrayUtil; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -60,10 +61,7 @@ public class FastStream implements Stream, Iterable { this.stream = stream; } - @SafeVarargs - private static Stream ofStream(E... values) { - return Objects.isNull(values) ? Stream.empty() : Arrays.stream(values); - } + // --------------------------------------------------------------- Static method start /** * 返回{@code FastStream}的建造器 @@ -99,7 +97,7 @@ public class FastStream implements Stream, Iterable { } /** - * 返回包含单个元素的串行流, 如果值为null, 则返回空的流, 不抛出异常 + * 返回包含单个元素的串行流 * * @param t 单个元素 * @param 元素类型 @@ -120,7 +118,7 @@ public class FastStream implements Stream, Iterable { @SafeVarargs @SuppressWarnings("varargs") public static FastStream of(T... values) { - return new FastStream<>(ofStream(values)); + return ArrayUtil.isEmpty(values) ? FastStream.empty() : new FastStream<>(Stream.of(values)); } /** @@ -280,6 +278,8 @@ public class FastStream implements Stream, Iterable { return Opt.ofBlankAble(str).map(CharSequence::toString).map(s -> s.split(regex)).map(FastStream::of).orElseGet(FastStream::empty); } + // --------------------------------------------------------------- Static method end + /** * 过滤元素,返回与指定断言匹配的元素组成的流 * 这是一个无状态中间操作 @@ -718,8 +718,8 @@ public class FastStream implements Stream, Iterable { * @throws ArrayStoreException 如果元素转换失败,例如不是该元素类型及其父类,则抛出该异常 * 例如以下代码编译正常,但运行时会抛出 {@link ArrayStoreException} *
{@code
-	 *                                                         String[] strings = Stream.builder().add(1).build().toArray(String[]::new);
-	 *                                                         }
+ * String[] strings = Stream.builder().add(1).build().toArray(String[]::new); + * } */ @Override public A[] toArray(IntFunction generator) { @@ -1094,7 +1094,7 @@ public class FastStream implements Stream, Iterable { * @return 流 */ public FastStream push(T obj) { - return FastStream.concat(this.stream, Stream.of(obj)); + return FastStream.concat(this.stream, of(obj)); } /** @@ -1105,7 +1105,7 @@ public class FastStream implements Stream, Iterable { */ @SuppressWarnings("unchecked") public FastStream push(T... obj) { - return FastStream.concat(this.stream, ofStream(obj)); + return FastStream.concat(this.stream, of(obj)); } /** @@ -1115,7 +1115,7 @@ public class FastStream implements Stream, Iterable { * @return 流 */ public FastStream unshift(T obj) { - return FastStream.concat(Stream.of(obj), this.stream); + return FastStream.concat(of(obj), this.stream); } /** @@ -1126,7 +1126,7 @@ public class FastStream implements Stream, Iterable { */ @SafeVarargs public final FastStream unshift(T... obj) { - return FastStream.concat(ofStream(obj), this.stream); + return FastStream.concat(of(obj), this.stream); } /**