You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/10/06 18:00:34 UTC

[groovy] branch GROOVY-8258 updated: GROOVY-8258: add `from` method to support nested ginq

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-8258
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY-8258 by this push:
     new 7276680  GROOVY-8258: add `from` method to support nested ginq
7276680 is described below

commit 7276680b7b06af2ea3b408dc4d22a364e590dcbd
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Oct 7 02:00:08 2020 +0800

    GROOVY-8258: add `from` method to support nested ginq
---
 .../groovy/org/apache/groovy/linq/provider/QueryableCollection.java   | 4 ++++
 .../org/apache/groovy/linq/provider/QueryableCollectionTest.groovy    | 1 +
 2 files changed, 5 insertions(+)

diff --git a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/provider/QueryableCollection.java b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/provider/QueryableCollection.java
index 9d5d19d..815a1fa 100644
--- a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/provider/QueryableCollection.java
+++ b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/provider/QueryableCollection.java
@@ -56,6 +56,10 @@ public class QueryableCollection<T> implements Queryable<T>, Iterable<T> {
         return from(sourceIterable);
     }
 
+    public static <T> Queryable<T> from(Queryable<T> queryable) {
+        return queryable;
+    }
+
     private QueryableCollection(Iterable<T> sourceIterable) {
         this.sourceIterable = sourceIterable;
         this.sourceStream = toStream(sourceIterable);
diff --git a/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/provider/QueryableCollectionTest.groovy b/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/provider/QueryableCollectionTest.groovy
index 344ffa4..9bf8d76 100644
--- a/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/provider/QueryableCollectionTest.groovy
+++ b/subprojects/groovy-linq/src/test/groovy/org/apache/groovy/linq/provider/QueryableCollectionTest.groovy
@@ -37,6 +37,7 @@ class QueryableCollectionTest {
     void testFrom() {
         assert [1, 2, 3] == from(Stream.of(1, 2, 3)).toList()
         assert [1, 2, 3] == from(Arrays.asList(1, 2, 3)).toList()
+        assert [1, 2, 3] == from(from(Arrays.asList(1, 2, 3))).toList()
     }
 
     @Test