// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java
// public class StreamDef implements Serializable {
// 
//     private String name;
//     private List<FlowOp> flowOps;
//     private boolean stdInput;
//     private boolean stdOutput;
//     private String[] outputs;
// 
//     public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) {
//       this.name = name;
//       this.flowOps = flowOps;
//       this.stdInput = stdInput;
//       this.stdOutput = stdOutput;
//       this.outputs = outputs;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public List<FlowOp> getFlowOps() {
//         return flowOps;
//     }
// 
//     public boolean isStdInput() {
//       return stdInput;
//     }
// 
//     public boolean isStdOutput() {
//       return stdOutput;
//     }
// 
//     public String[] getOutputs() {
//       return outputs;
//     }
// 
//     @Override
//     public String toString() {
//         return "StreamDef{" +
//                 "name='" + name + '\'' +
//                 ", flowOps=" + flowOps +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//       if (this == o) {
//         return true;
//       }
//       if (o == null || getClass() != o.getClass()) {
//         return false;
//       }
// 
//       StreamDef streamDef = (StreamDef) o;
// 
//       if (stdInput != streamDef.stdInput) {
//         return false;
//       }
//       if (stdOutput != streamDef.stdOutput) {
//         return false;
//       }
//       if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) {
//         return false;
//       }
//       if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) {
//         return false;
//       }
//       if (!Arrays.equals(outputs, streamDef.outputs)) {
//         return false;
//       }
// 
//       return true;
//     }
// 
//     @Override
//     public int hashCode() {
//       int result = name != null ? name.hashCode() : 0;
//       result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0);
//       result = 31 * result + (stdInput ? 1 : 0);
//       result = 31 * result + (stdOutput ? 1 : 0);
//       result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0);
//       return result;
//     }
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java
// public interface FlowOp extends Serializable {
// 
//     String getComponentName();
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java
// public class JoinOp implements FlowOp, RequiresPartitioning {
// 
//     public static final String JOIN = "join";
// 
//     String leftStream;
//     String rightStream;
// 
//     Policy evictionPolicy;
//     long evictionThreshold;
// 
//     public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) {
//         this.leftStream = leftStream;
//         this.rightStream = rightStream;
//         this.evictionPolicy = evictionPolicy;
//         this.evictionThreshold = evictionThreshold;
//     }
// 
//     public String getLeftStream() {
//         return leftStream;
//     }
// 
//     public String getRightStream() {
//         return rightStream;
//     }
// 
//     public Policy getEvictionPolicy() {
//         return evictionPolicy;
//     }
// 
//     public long getEvictionThreshold() {
//         return evictionThreshold;
//     }
// 
//     @Override
//     public String getComponentName() {
//         return "join";
//     }
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.calrissian.flowmix.core.model.StreamDef;
import org.calrissian.flowmix.core.model.op.FlowOp;
import org.calrissian.flowmix.core.model.op.JoinOp;
      boolean oneStdOut = false;
      boolean oneStdIn = false;
      Map<String, Set<String>> inputs = new HashMap<String, Set<String>>();
      for(StreamDef def : getStreamList()) {
        if(def.isStdInput())
          oneStdIn = true;

        if(def.isStdOutput())
          oneStdOut = true;

        if(def.getOutputs() != null) {
          for(String output : def.getOutputs()) {
            Set<String> entry = inputs.get(output);
            if(entry == null) {
              entry = new HashSet<String>();
              inputs.put(output, entry);
            }
            entry.add(def.getName());
          }
        }
      }

      if(!oneStdIn)
        throw new RuntimeException("At least one stream needs to read from std input");

      if(!oneStdOut)
        throw new RuntimeException("At least one stream needs to write to std output");

      for(StreamDef def : getStreamList()) {
        for(FlowOp op : def.getFlowOps()) {
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java
// public class StreamDef implements Serializable {
// 
//     private String name;
//     private List<FlowOp> flowOps;
//     private boolean stdInput;
//     private boolean stdOutput;
//     private String[] outputs;
// 
//     public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) {
//       this.name = name;
//       this.flowOps = flowOps;
//       this.stdInput = stdInput;
//       this.stdOutput = stdOutput;
//       this.outputs = outputs;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public List<FlowOp> getFlowOps() {
//         return flowOps;
//     }
// 
//     public boolean isStdInput() {
//       return stdInput;
//     }
// 
//     public boolean isStdOutput() {
//       return stdOutput;
//     }
// 
//     public String[] getOutputs() {
//       return outputs;
//     }
// 
//     @Override
//     public String toString() {
//         return "StreamDef{" +
//                 "name='" + name + '\'' +
//                 ", flowOps=" + flowOps +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//       if (this == o) {
//         return true;
//       }
//       if (o == null || getClass() != o.getClass()) {
//         return false;
//       }
// 
//       StreamDef streamDef = (StreamDef) o;
// 
//       if (stdInput != streamDef.stdInput) {
//         return false;
//       }
//       if (stdOutput != streamDef.stdOutput) {
//         return false;
//       }
//       if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) {
//         return false;
//       }
//       if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) {
//         return false;
//       }
//       if (!Arrays.equals(outputs, streamDef.outputs)) {
//         return false;
//       }
// 
//       return true;
//     }
// 
//     @Override
//     public int hashCode() {
//       int result = name != null ? name.hashCode() : 0;
//       result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0);
//       result = 31 * result + (stdInput ? 1 : 0);
//       result = 31 * result + (stdOutput ? 1 : 0);
//       result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0);
//       return result;
//     }
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java
// public interface FlowOp extends Serializable {
// 
//     String getComponentName();
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java
// public class JoinOp implements FlowOp, RequiresPartitioning {
// 
//     public static final String JOIN = "join";
// 
//     String leftStream;
//     String rightStream;
// 
//     Policy evictionPolicy;
//     long evictionThreshold;
// 
//     public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) {
//         this.leftStream = leftStream;
//         this.rightStream = rightStream;
//         this.evictionPolicy = evictionPolicy;
//         this.evictionThreshold = evictionThreshold;
//     }
// 
//     public String getLeftStream() {
//         return leftStream;
//     }
// 
//     public String getRightStream() {
//         return rightStream;
//     }
// 
//     public Policy getEvictionPolicy() {
//         return evictionPolicy;
//     }
// 
//     public long getEvictionThreshold() {
//         return evictionThreshold;
//     }
// 
//     @Override
//     public String getComponentName() {
//         return "join";
//     }
// }


// Path: src/main/java/org/calrissian/flowmix/api/builder/FlowDefsBuilder.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.calrissian.flowmix.core.model.StreamDef;
import org.calrissian.flowmix.core.model.op.FlowOp;
import org.calrissian.flowmix.core.model.op.JoinOp;

      boolean oneStdOut = false;
      boolean oneStdIn = false;
      Map<String, Set<String>> inputs = new HashMap<String, Set<String>>();
      for(StreamDef def : getStreamList()) {
        if(def.isStdInput())
          oneStdIn = true;

        if(def.isStdOutput())
          oneStdOut = true;

        if(def.getOutputs() != null) {
          for(String output : def.getOutputs()) {
            Set<String> entry = inputs.get(output);
            if(entry == null) {
              entry = new HashSet<String>();
              inputs.put(output, entry);
            }
            entry.add(def.getName());
          }
        }
      }

      if(!oneStdIn)
        throw new RuntimeException("At least one stream needs to read from std input");

      if(!oneStdOut)
        throw new RuntimeException("At least one stream needs to write to std output");

      for(StreamDef def : getStreamList()) {
        for(FlowOp op : def.getFlowOps()) {
          if(op instanceof JoinOp) {