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

graphql.kickstart.execution.subscriptions.AtomicSubscriptionSubscription Maven / Gradle / Ivy

The newest version!
package graphql.kickstart.execution.subscriptions;

import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;

public class AtomicSubscriptionSubscription {

  private final AtomicReference reference = new AtomicReference<>(null);

  public void set(Subscription subscription) {
    if (reference.get() != null) {
      throw new IllegalStateException("Cannot overwrite subscription!");
    }

    reference.set(subscription);
  }

  public Subscription get() {
    Subscription subscription = reference.get();
    if (subscription == null) {
      throw new IllegalStateException("Subscription has not been initialized yet!");
    }

    return subscription;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy