This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class App { | |
| public static void main(String[] args) { | |
| Sink<Double> sink = new DataSource<>(Arrays.asList("1", "2", "3", "4").iterator()) | |
| .transform(s -> Integer.parseInt(s)) | |
| .transform(i -> (double) i) | |
| .sink(i -> System.out.println("The result is: " + i)); | |
| // prints 1.0, 2.0, 3.0, 4.0 | |
| sink.execute(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public interface ApplyResult<T> { | |
| void apply(T message); | |
| } | |
| public final class Sink<T> { | |
| private final Iterator<T> source; | |
| private final ApplyResult<T> sink; | |
| Sink(Iterator<T> source, ApplyResult<T> sink) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public interface ApplyFunction<T, D> { | |
| D apply(T input); | |
| } | |
| public final class Tranformation<T, D> implements Iterator<D> { | |
| private final Iterator<T> source; | |
| private final ApplyFunction<T, D> transformer; | |
| Tranformation(Iterator<T> source, ApplyFunction<T, D> transformer) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public final class DataSource<T> { | |
| private Iterator<T> source; | |
| DataSource(Iterator<T> source) { | |
| this.source = source; | |
| } | |
| public <D> Tranformation<T, D> transform(Tranformation<T, D> transformer) { | |
| return new Tranformation<>(source, transformer); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class FileLineReader implements Iterable<String> { | |
| private final File inputFile; | |
| FileLineReader(File inputFile) { | |
| this.inputFile = inputFile; | |
| } | |
| @Override | |
| public Iterator<String> iterator() { |