Producers { public static <T> Producer<T> producerFromProvider(final Provider<T> provider) { checkNotNull(provider); return new AbstractProducer<T>() { @Override protected ListenableFuture<T> compute() { return Futures.immediateFuture(provider.get()); } }; } private  Producers(); static ListenableFuture<Produced<T>> createFutureProduced(ListenableFuture<T> future); static ListenableFuture<Set<T>> createFutureSingletonSet(ListenableFuture<T> future); static ListenableFuture<T> submitToExecutor(Callable<T> callable, Executor executor); static Producer<T> producerFromProvider(final Provider<T> provider);  }
@Test public void producerFromProvider() throws Exception { Producer<Integer> producer = Producers.producerFromProvider(new Provider<Integer>() { int i = 0; @Override public Integer get() { return i++; } }); assertThat(producer.get().get()).isEqualTo(0); assertThat(producer.get().get()).isEqualTo(0); assertThat(producer.get().get()).isEqualTo(0); }