You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/05/17 20:05:04 UTC
ant git commit: Missed a piece of a file…
Repository: ant
Updated Branches:
refs/heads/master 114226309 -> 3f5a4d875
Missed a piece of a file…
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/3f5a4d87
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/3f5a4d87
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/3f5a4d87
Branch: refs/heads/master
Commit: 3f5a4d8752a2441acbea88a83785a98471d6c366
Parents: 1142263
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Thu May 17 22:04:23 2018 +0200
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Thu May 17 22:04:53 2018 +0200
----------------------------------------------------------------------
.../org/apache/tools/ant/util/StreamUtils.java | 35 +++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/3f5a4d87/src/main/org/apache/tools/ant/util/StreamUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/StreamUtils.java b/src/main/org/apache/tools/ant/util/StreamUtils.java
index f64f412..0f0950c 100644
--- a/src/main/org/apache/tools/ant/util/StreamUtils.java
+++ b/src/main/org/apache/tools/ant/util/StreamUtils.java
@@ -1,6 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.tools.ant.util;
import java.util.Enumeration;
+import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
@@ -26,8 +44,23 @@ public class StreamUtils {
return false;
}
public void forEachRemaining(Consumer<? super T> action) {
- while(e.hasMoreElements()) action.accept(e.nextElement());
+ while (e.hasMoreElements()) {
+ action.accept(e.nextElement());
+ }
}
}, false);
}
+
+ /**
+ * Turn Iterator into a Stream
+ *
+ * @param <T> Iterator type
+ * @param i Iterator
+ * @return Stream
+ */
+ public static <T> Stream<T> iteratorAsStream(Iterator<T> i) {
+ return StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(i, Spliterator.ORDERED),
+ false);
+ }
}