ManagementOperation extends FutureTask<R> { @NotNull public static <R> ManagementOperation<R> done(String name, final R result) { return new ManagementOperation<R>("done", () -> "", new Callable<R>() { @Override public R call() throws Exception { return result; } }) { @Override public boolean isDone() { return true; } @Override public R get() { return result; } @Override public void run() { throw new IllegalStateException("This task is done"); } @Override public Status getStatus() { return none(this, "NA"); } }; } private  ManagementOperation(
            @NotNull String name,
            @NotNull Supplier<String> statusMessage,
            @NotNull Callable<R> task); static ManagementOperation<R> newManagementOperation(
            @NotNull String name,
            @NotNull Callable<R> task); static ManagementOperation<R> newManagementOperation(
            @NotNull String name,
            @NotNull Supplier<String> statusMessage,
            @NotNull Callable<R> task); @Deprecated static ManagementOperation<R> newManagementOperation(
            @NotNull String name,
            @NotNull com.google.common.base.Supplier<String> statusMessage,
            @NotNull Callable<R> task); @NotNull static ManagementOperation<R> done(String name, final R result); int getId(); @NotNull String getName(); @NotNull Status getStatus(); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void notStarted() throws ExecutionException, InterruptedException { ManagementOperation<Integer> op = ManagementOperation.done("test", 42); assertTrue(op.isDone()); assertEquals(42, (int) op.get()); sameThreadExecutor().execute(op); }