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

streak.FailStreamSource Maven / Gradle / Ivy

The newest version!
package streak;

import java.util.Objects;
import javax.annotation.Nonnull;

final class FailStreamSource
  extends Stream
{
  @Nonnull
  private final Throwable _error;

  FailStreamSource( @Nonnull final Throwable error )
  {
    _error = Objects.requireNonNull( error );
  }

  @Override
  protected void doSubscribe( @Nonnull final Subscriber subscriber )
  {
    final WorkerSubscription subscription = new WorkerSubscription<>();
    subscriber.onSubscribe( subscription );
    subscriber.onError( _error );
    subscription.cancel();
  }

  private static final class WorkerSubscription
    implements Subscription
  {
    private WorkerSubscription()
    {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void cancel()
    {
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy