private synchronized void activate(Optional<ApolloPrefetch.Callback> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerPrefetchCall(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<ApolloCall.Callback<T>> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerQueryWatcher(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
@Override public void execute(@NotNull Callback<T> callback) throws ApolloCanceledException { checkNotNull(callback, "callback == null"); synchronized (this) { switch (state.get()) { case IDLE: { state.set(ACTIVE); subscriptionCallback = new SubscriptionManagerCallback<>(callback, this); subscriptionManager.subscribe(subscription, subscriptionCallback); break; } case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } } }
@SuppressWarnings("ResultOfMethodCallIgnored") private synchronized void activate(Optional<Callback<T>> callback) { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerCall(this); callback.apply(new Action<Callback<T>>() { @Override public void apply(@NotNull Callback<T> callback) { callback.onStatusEvent(StatusEvent.SCHEDULED); } }); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<Callback> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerPrefetchCall(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<GraphQLCall.Callback<T>> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerQueryWatcher(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<GraphQLCall.Callback<T>> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerQueryWatcher(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<Callback> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerPrefetchCall(this); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<Callback<T>> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerCall(this); callback.apply(new Action<Callback<T>>() { @Override public void apply(@Nonnull Callback<T> callback) { callback.onStatusEvent(StatusEvent.SCHEDULED); } }); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
private synchronized void activate(Optional<Callback<T>> callback) throws ApolloCanceledException { switch (state.get()) { case IDLE: originalCallback.set(callback.orNull()); tracker.registerCall(this); callback.apply(new Action<Callback<T>>() { @Override public void apply(@Nonnull Callback<T> callback) { callback.onStatusEvent(StatusEvent.SCHEDULED); } }); break; case CANCELED: throw new ApolloCanceledException("Call is cancelled."); case TERMINATED: case ACTIVE: throw new IllegalStateException("Already Executed"); default: throw new IllegalStateException("Unknown state"); } state.set(ACTIVE); }
throw new RuntimeException("Cancelled", new ApolloCanceledException("Call is cancelled."));
throw new RuntimeException("Cancelled", new ApolloCanceledException("Call is cancelled."));