|
|
@@ -8,6 +8,7 @@ package net.ranides.assira.collection;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* Dynamic view with elements from merged collections.
|
|
|
@@ -29,6 +30,10 @@ public class FlatCollection<T> extends AbstractCollection<T> implements Serializ
|
|
|
joinAll(Arrays.asList(values));
|
|
|
}
|
|
|
|
|
|
+ public FlatCollection(Stream<Collection<T>> values) {
|
|
|
+ joinAll(values);
|
|
|
+ }
|
|
|
+
|
|
|
public FlatCollection(Collection<Collection<T>> values) {
|
|
|
joinAll(values);
|
|
|
}
|
|
|
@@ -49,7 +54,7 @@ public class FlatCollection<T> extends AbstractCollection<T> implements Serializ
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * Inserts into view specified collections.
|
|
|
+ * Inserts specified collections into view.
|
|
|
* Note: It stores containers, not actual elements from them.
|
|
|
* @param list
|
|
|
* @return
|
|
|
@@ -59,6 +64,17 @@ public class FlatCollection<T> extends AbstractCollection<T> implements Serializ
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * Inserts specified collections into view.
|
|
|
+ * Note: It stores containers, not actual elements from them.
|
|
|
+ * @param stream
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public final FlatCollection<T> joinAll(Stream<Collection<T>> stream) {
|
|
|
+ stream.forEachOrdered(content::add);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int size() {
|
|
|
int size = 0;
|