@Test public void testOnSuccess() { Continuation<Integer, Integer> continuation = new Continuation<Integer, Integer>() { public Integer then(Task<Integer> task) { return task.getResult() + 1; } }; Task<Integer> complete = Task.forResult(5).onSuccess(continuation); Task<Integer> error = Task.<Integer> forError(new IllegalStateException()).onSuccess( continuation); Task<Integer> cancelled = Task.<Integer> cancelled().onSuccess(continuation); assertTrue(complete.isCompleted()); assertEquals(6, complete.getResult().intValue()); assertFalse(complete.isFaulted()); assertFalse(complete.isCancelled()); assertTrue(error.isCompleted()); assertTrue(error.getError() instanceof RuntimeException); assertTrue(error.isFaulted()); assertFalse(error.isCancelled()); assertTrue(cancelled.isCompleted()); assertFalse(cancelled.isFaulted()); assertTrue(cancelled.isCancelled()); }
public <TContinuationResult> Task<TContinuationResult> onSuccess( final Continuation<TResult, TContinuationResult> continuation, Executor executor) { return onSuccess(continuation, executor, null); }
Task { public <TContinuationResult> Task<TContinuationResult> onSuccess( final Continuation<TResult, TContinuationResult> continuation, Executor executor) { return onSuccess(continuation, executor, null); } }
Task { public <TContinuationResult> Task<TContinuationResult> onSuccess( final Continuation<TResult, TContinuationResult> continuation, Executor executor) { return onSuccess(continuation, executor, null); } Task(); private  Task(TResult result); private  Task(boolean cancelled); }
Task { public <TContinuationResult> Task<TContinuationResult> onSuccess( final Continuation<TResult, TContinuationResult> continuation, Executor executor) { return onSuccess(continuation, executor, null); } Task(); private  Task(TResult result); private  Task(boolean cancelled); static UnobservedExceptionHandler getUnobservedExceptionHandler(); static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh); static Task<TResult>.TaskCompletionSource create(); boolean isCompleted(); boolean isCancelled(); boolean isFaulted(); TResult getResult(); Exception getError(); void waitForCompletion(); boolean waitForCompletion(long duration, TimeUnit timeUnit); @SuppressWarnings("unchecked") static Task<TResult> forResult(TResult value); static Task<TResult> forError(Exception error); @SuppressWarnings("unchecked") static Task<TResult> cancelled(); static Task<Void> delay(long delay); static Task<Void> delay(long delay, CancellationToken cancellationToken); Task<TOut> cast(); Task<Void> makeVoid(); static Task<TResult> callInBackground(Callable<TResult> callable); static Task<TResult> callInBackground(Callable<TResult> callable, CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable, Executor executor); static Task<TResult> call(final Callable<TResult> callable, Executor executor,
      final CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable); static Task<TResult> call(final Callable<TResult> callable, CancellationToken ct); static Task<Task<TResult>> whenAnyResult(Collection<? extends Task<TResult>> tasks); @SuppressWarnings("unchecked") static Task<Task<?>> whenAny(Collection<? extends Task<?>> tasks); static Task<List<TResult>> whenAllResult(final Collection<? extends Task<TResult>> tasks); static Task<Void> whenAll(Collection<? extends Task<?>> tasks); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation, CancellationToken ct); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation, CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation,
      CancellationToken ct); }
Task { public <TContinuationResult> Task<TContinuationResult> onSuccess( final Continuation<TResult, TContinuationResult> continuation, Executor executor) { return onSuccess(continuation, executor, null); } Task(); private  Task(TResult result); private  Task(boolean cancelled); static UnobservedExceptionHandler getUnobservedExceptionHandler(); static void setUnobservedExceptionHandler(UnobservedExceptionHandler eh); static Task<TResult>.TaskCompletionSource create(); boolean isCompleted(); boolean isCancelled(); boolean isFaulted(); TResult getResult(); Exception getError(); void waitForCompletion(); boolean waitForCompletion(long duration, TimeUnit timeUnit); @SuppressWarnings("unchecked") static Task<TResult> forResult(TResult value); static Task<TResult> forError(Exception error); @SuppressWarnings("unchecked") static Task<TResult> cancelled(); static Task<Void> delay(long delay); static Task<Void> delay(long delay, CancellationToken cancellationToken); Task<TOut> cast(); Task<Void> makeVoid(); static Task<TResult> callInBackground(Callable<TResult> callable); static Task<TResult> callInBackground(Callable<TResult> callable, CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable, Executor executor); static Task<TResult> call(final Callable<TResult> callable, Executor executor,
      final CancellationToken ct); static Task<TResult> call(final Callable<TResult> callable); static Task<TResult> call(final Callable<TResult> callable, CancellationToken ct); static Task<Task<TResult>> whenAnyResult(Collection<? extends Task<TResult>> tasks); @SuppressWarnings("unchecked") static Task<Task<?>> whenAny(Collection<? extends Task<?>> tasks); static Task<List<TResult>> whenAllResult(final Collection<? extends Task<TResult>> tasks); static Task<Void> whenAll(Collection<? extends Task<?>> tasks); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation); Task<Void> continueWhile(Callable<Boolean> predicate,
      Continuation<Void, Task<Void>> continuation, CancellationToken ct); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor); Task<Void> continueWhile(final Callable<Boolean> predicate,
      final Continuation<Void, Task<Void>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor); Task<TContinuationResult> continueWith(
      final Continuation<TResult, TContinuationResult> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> continueWith(
      Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor); Task<TContinuationResult> continueWithTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor,
      final CancellationToken ct); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> continueWithTask(
      Continuation<TResult, Task<TContinuationResult>> continuation, CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation); Task<TContinuationResult> onSuccess(
      final Continuation<TResult, TContinuationResult> continuation, CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation, Executor executor,
      final CancellationToken ct); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation); Task<TContinuationResult> onSuccessTask(
      final Continuation<TResult, Task<TContinuationResult>> continuation,
      CancellationToken ct); static final ExecutorService BACKGROUND_EXECUTOR; static final Executor UI_THREAD_EXECUTOR; }