|
@@ -56,6 +56,11 @@ public abstract class CQueryAbstract<T> implements CQuery<T> {
|
|
|
return stream().collect(Collectors.toSet());
|
|
return stream().collect(Collectors.toSet());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CQuery<T> append(CQuery<T> next) {
|
|
|
|
|
+ return new CQMerge<>(this, next);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public final CQuery<T> fetch() {
|
|
public final CQuery<T> fetch() {
|
|
|
return CQueryBuilder.fromCollection(list());
|
|
return CQueryBuilder.fromCollection(list());
|
|
@@ -464,7 +469,41 @@ public abstract class CQueryAbstract<T> implements CQuery<T> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ protected static class CQMerge<T> extends CQueryAbstract<T> {
|
|
|
|
|
+
|
|
|
|
|
+ private final List<CQuery<T>> source;
|
|
|
|
|
+
|
|
|
|
|
+ public CQMerge(CQuery<T> a, CQuery<T> b) {
|
|
|
|
|
+ this.source = Arrays.asList(a,b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public CQMerge(CQMerge<T> a, CQuery<T> b) {
|
|
|
|
|
+ this.source = new ArrayList<>(a.source);
|
|
|
|
|
+ this.source.add(b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Stream<T> stream() {
|
|
|
|
|
+ return source.stream().flatMap(CQuery::stream);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int size() {
|
|
|
|
|
+ return source.stream().map(CQuery::size).reduce(0, Integer::sum);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Iterator<T> iterator() {
|
|
|
|
|
+ return source.stream().flatMap(CQuery::stream).iterator();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CQuery<T> append(CQuery<T> next) {
|
|
|
|
|
+ return new CQMerge<>(this, next);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static final class BIterator<T> implements Iterator<T> {
|
|
private static final class BIterator<T> implements Iterator<T> {
|
|
|
|
|
|
|
|
private final Iterator<T> src;
|
|
private final Iterator<T> src;
|