// Path: src/main/java/org/calrissian/flowmix/api/Policy.java
// public enum Policy implements Serializable {
// 
//     COUNT, TIME, TIME_DELTA_LT
// }
// 
// 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/PartitionOp.java
// public class PartitionOp implements FlowOp {
// 
//   public static final String PARTITION = "partition";
//   private List<String> fields;
// 
//   public PartitionOp(List<String> fields) {
//       this.fields = fields;
//   }
// 
//   public List<String> getFields() {
//       return fields;
//   }
// 
//   @Override
//   public String getComponentName() {
//       return PARTITION;
//   }
// 
//   @Override
//   public String toString() {
//     return "PartitionOp{" +
//             "fields=" + fields +
//             '}';
//   }
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java
// public class SwitchOp implements FlowOp, RequiresPartitioning {
// 
//     public static final String SWITCH = "stopGate";
//     private Policy openPolicy;
//     private Policy evictionPolicy;
//     private Policy closePolicy;
// 
//     private long openThreshold;
//     private long evictionThreshold;
//     private long closeThreshold;
// 
//     public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold,
//                     long evictionThreshold, long closeThreshold) {
//         this.openPolicy = openPolicy;
//         this.evictionPolicy = evictionPolicy;
//         this.closePolicy = closePolicy;
//         this.openThreshold = openThreshold;
//         this.evictionThreshold = evictionThreshold;
//         this.closeThreshold = closeThreshold;
//     }
// 
//     public Policy getOpenPolicy() {
//         return openPolicy;
//     }
// 
//     public Policy getEvictionPolicy() {
//         return evictionPolicy;
//     }
// 
//     public Policy getClosePolicy() {
//         return closePolicy;
//     }
// 
//     public long getOpenThreshold() {
//         return openThreshold;
//     }
// 
//     public long getEvictionThreshold() {
//         return evictionThreshold;
//     }
// 
//     public long getCloseThreshold() {
//         return closeThreshold;
//     }
// 
//     @Override
//     public String getComponentName() {
//         return SWITCH;
//     }
// }


import java.util.List;
import org.calrissian.flowmix.api.Policy;
import org.calrissian.flowmix.core.model.op.FlowOp;
import org.calrissian.flowmix.core.model.op.PartitionOp;
import org.calrissian.flowmix.core.model.op.SwitchOp;
import static java.util.Collections.EMPTY_LIST;
    public SwitchBuilder open(Policy policy, long threshold) {
        this.openPolicy = policy;
        this.openThreshold = threshold;
        return this;
    }

    public SwitchBuilder evict(Policy policy, long threshold) {
        this.evictionPolicy = policy;
        this.evictionThreshold = threshold;
        return this;
    }

    public SwitchBuilder close(Policy policy, long openThreshold) {
        this.closePolicy = policy;
        this.closeThreshold = openThreshold;
        return this;
    }

    @Override
    public StreamBuilder end() {

      if(openPolicy == null || openThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an activation policy and threshold");

      if(evictionPolicy == null || evictionThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an eviction policy and threshold");

      if(closePolicy == null || closeThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an close policy and threshold");

// Path: src/main/java/org/calrissian/flowmix/api/Policy.java
// public enum Policy implements Serializable {
// 
//     COUNT, TIME, TIME_DELTA_LT
// }
// 
// 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/PartitionOp.java
// public class PartitionOp implements FlowOp {
// 
//   public static final String PARTITION = "partition";
//   private List<String> fields;
// 
//   public PartitionOp(List<String> fields) {
//       this.fields = fields;
//   }
// 
//   public List<String> getFields() {
//       return fields;
//   }
// 
//   @Override
//   public String getComponentName() {
//       return PARTITION;
//   }
// 
//   @Override
//   public String toString() {
//     return "PartitionOp{" +
//             "fields=" + fields +
//             '}';
//   }
// }
// 
// Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java
// public class SwitchOp implements FlowOp, RequiresPartitioning {
// 
//     public static final String SWITCH = "stopGate";
//     private Policy openPolicy;
//     private Policy evictionPolicy;
//     private Policy closePolicy;
// 
//     private long openThreshold;
//     private long evictionThreshold;
//     private long closeThreshold;
// 
//     public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold,
//                     long evictionThreshold, long closeThreshold) {
//         this.openPolicy = openPolicy;
//         this.evictionPolicy = evictionPolicy;
//         this.closePolicy = closePolicy;
//         this.openThreshold = openThreshold;
//         this.evictionThreshold = evictionThreshold;
//         this.closeThreshold = closeThreshold;
//     }
// 
//     public Policy getOpenPolicy() {
//         return openPolicy;
//     }
// 
//     public Policy getEvictionPolicy() {
//         return evictionPolicy;
//     }
// 
//     public Policy getClosePolicy() {
//         return closePolicy;
//     }
// 
//     public long getOpenThreshold() {
//         return openThreshold;
//     }
// 
//     public long getEvictionThreshold() {
//         return evictionThreshold;
//     }
// 
//     public long getCloseThreshold() {
//         return closeThreshold;
//     }
// 
//     @Override
//     public String getComponentName() {
//         return SWITCH;
//     }
// }


// Path: src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java
import java.util.List;
import org.calrissian.flowmix.api.Policy;
import org.calrissian.flowmix.core.model.op.FlowOp;
import org.calrissian.flowmix.core.model.op.PartitionOp;
import org.calrissian.flowmix.core.model.op.SwitchOp;
import static java.util.Collections.EMPTY_LIST;

    public SwitchBuilder open(Policy policy, long threshold) {
        this.openPolicy = policy;
        this.openThreshold = threshold;
        return this;
    }

    public SwitchBuilder evict(Policy policy, long threshold) {
        this.evictionPolicy = policy;
        this.evictionThreshold = threshold;
        return this;
    }

    public SwitchBuilder close(Policy policy, long openThreshold) {
        this.closePolicy = policy;
        this.closeThreshold = openThreshold;
        return this;
    }

    @Override
    public StreamBuilder end() {

      if(openPolicy == null || openThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an activation policy and threshold");

      if(evictionPolicy == null || evictionThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an eviction policy and threshold");

      if(closePolicy == null || closeThreshold == -1)
          throw new RuntimeException("Stop gate operator must have an close policy and threshold");

      List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList();