graphql.kickstart.execution.subscriptions.AtomicSubscriptionSubscription Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-kickstart-jakarta5 Show documentation
Show all versions of graphql-java-kickstart-jakarta5 Show documentation
relay.js-compatible GraphQL servlet
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;
}
}