Ejemplo n.º 1
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]);
      }
    }
  }