Esempio n. 1
0
 /**
  * Single parameter constructor that specifies the unique id of the node.
  *
  * @param id
  */
 protected LeftTupleSource(int id, BuildContext context) {
   super(
       id,
       context != null ? context.getPartitionId() : RuleBasePartitionId.MAIN_PARTITION,
       context != null && context.getKnowledgeBase().getConfiguration().isMultithreadEvaluation());
   this.sink = EmptyLeftTupleSinkAdapter.getInstance();
 }
Esempio n. 2
0
  /**
   * Removes the <code>TupleSink</code>
   *
   * @param tupleSink The <code>TupleSink</code> to remove
   */
  public void removeTupleSink(final LeftTupleSink tupleSink) {
    if (this.sink instanceof EmptyLeftTupleSinkAdapter) {
      throw new IllegalArgumentException("Cannot remove a sink, when the list of sinks is null");
    }

    if (this.sink instanceof SingleLeftTupleSinkAdapter) {
      this.sink = EmptyLeftTupleSinkAdapter.getInstance();
    } else {
      final CompositeLeftTupleSinkAdapter sinkAdapter = (CompositeLeftTupleSinkAdapter) this.sink;
      sinkAdapter.removeTupleSink(tupleSink);
      if (sinkAdapter.size() == 1) {
        this.sink =
            new SingleLeftTupleSinkAdapter(this.getPartitionId(), sinkAdapter.getSinks()[0]);
      }
    }
  }