package streaming.api;

import java.util.Collection;
import java.util.function.Supplier;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class SupplyChain {




    private Stream<String> currentStream;

    private SupplyChain() {
        this.currentStream = Stream.empty();
    }

    private SupplyChain(Stream<String> stream) {
        this.currentStream = stream;
    }

    public static SupplyChain newSupplyChain() {
        return new SupplyChain();
    }

    private SupplyChain add(Stream<String> newStream) {
        return new SupplyChain(Stream.concat(currentStream, newStream));
    }


    public InfiniteStringSupplierBuilder take(int amount) {
        return new InfiniteStringSupplierBuilder(amount);
    }

    public SupplyChain then() {
        return this;
    }

    public FiniteSupplierBuilder takeAll() {
        return new FiniteSupplierBuilder();
    }

    public Stream<String> build() {
        return currentStream;
    }

    public class InfiniteStringSupplierBuilder {
        private final SupplyChain supplier;

        final int amount;

        private InfiniteStringSupplierBuilder(int amount) {
            this.supplier = SupplyChain.this;
            this.amount = amount;
        }

        public SupplyChain from(Supplier<String> stringSupplier) {

            Stream<String> s = Stream.generate(stringSupplier);
            return supplier.add(s.limit(amount));
        }

    }

    public class FiniteSupplierBuilder {

        public static final boolean NOT_PARALLEL = false;
        final SupplyChain supplier;

        public FiniteSupplierBuilder() {
            supplier = SupplyChain.this;
        }


        public SupplyChain from(Collection<String> stringCollection) {
            return supplier.add(StreamSupport.stream(stringCollection.spliterator(), NOT_PARALLEL));
        }
    }
}

@@ -516,17 +516,20 @@
 yChain a
-d
+ppen
 d(Stream
@@ -642,30 +642,22 @@
  public 
-InfiniteString
+Stream
 Supplier
@@ -702,30 +702,22 @@
 urn new 
-InfiniteString
+Stream
 Supplier
@@ -803,38 +803,42 @@
   %7D%0A%0A    public 
-Finite
+Collection
 SupplierBuilder 
@@ -868,22 +868,26 @@
 urn new 
-Finite
+Collection
 Supplier
@@ -994,30 +994,22 @@
 c class 
-InfiniteString
+Stream
 Supplier
@@ -1110,22 +1110,14 @@
 ate 
-InfiniteString
+Stream
 Supp
@@ -1394,17 +1394,20 @@
 pplier.a
-d
+ppen
 d(s.limi
@@ -1453,22 +1453,26 @@
 c class 
-Finite
+Collection
 Supplier
@@ -1596,14 +1596,18 @@
 lic 
-Finite
+Collection
 Supp
@@ -1775,17 +1775,20 @@
 pplier.a
-d
+ppen
 d(Stream

rename inner classes