All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.pincette.rs.Delegate Maven / Gradle / Ivy

package net.pincette.rs;

import java.util.concurrent.Flow.Processor;
import java.util.concurrent.Flow.Subscriber;
import java.util.concurrent.Flow.Subscription;

/**
 * Delegates all operations to a given processor.
 *
 * @param  the incoming value type.
 * @param  the outgoing value type.
 * @author Werner Donn\u00e9
 * @since 3.0
 */
public class Delegate implements Processor {
  protected final Processor delegateTo;

  public Delegate(final Processor delegateTo) {
    this.delegateTo = delegateTo;
  }

  public static  Processor delegate(final Processor delegateTo) {
    return new Delegate<>(delegateTo);
  }

  public void onComplete() {
    delegateTo.onComplete();
  }

  public void onError(final Throwable t) {
    delegateTo.onError(t);
  }

  public void onNext(final T value) {
    delegateTo.onNext(value);
  }

  public void onSubscribe(final Subscription subscription) {
    delegateTo.onSubscribe(subscription);
  }

  public void subscribe(final Subscriber subscriber) {
    if (subscriber == null) {
      throw new NullPointerException("A subscriber can't be null.");
    }

    delegateTo.subscribe(subscriber);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy