@Test public void canListenForImmediateResult() { Object result = mock(Object.class); final ListenableFuture<Object> future = Futures.immediateFuture(result); final AtomicReference<Object> resultRef = new AtomicReference<>(null); Futures.addCallback(future, new FutureCallback<Object>() { @Override public void onSuccess(@Nullable Object result) { resultRef.set(result); } @Override public void onFailure(Throwable t) { } }, CameraXExecutors.directExecutor()); assertThat(resultRef.get()).isSameInstanceAs(result); }
@Override @Nullable public abstract V get() throws ExecutionException;
ImmediateFuture implements ListenableFuture<V> { @Override @Nullable public abstract V get() throws ExecutionException; }
ImmediateFuture implements ListenableFuture<V> { @Override @Nullable public abstract V get() throws ExecutionException;  }
ImmediateFuture implements ListenableFuture<V> { @Override @Nullable public abstract V get() throws ExecutionException;  static ListenableFuture<V> nullFuture(); @Override void addListener(@NonNull Runnable listener, @NonNull Executor executor); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override @Nullable abstract V get(); @Override @Nullable V get(long timeout, @NonNull TimeUnit unit); }
ImmediateFuture implements ListenableFuture<V> { @Override @Nullable public abstract V get() throws ExecutionException;  static ListenableFuture<V> nullFuture(); @Override void addListener(@NonNull Runnable listener, @NonNull Executor executor); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override @Nullable abstract V get(); @Override @Nullable V get(long timeout, @NonNull TimeUnit unit);  }