/** * Creates a {@code ListenableFuture} which has its value set immediately upon construction. The * getters just return the value. This {@code Future} can't be canceled or timed out and its * {@code isDone()} method always returns {@code true}. */ public static <V> ListenableFuture<V> immediateFuture(@Nullable V value) { if (value == null) { // This cast is safe because null is assignable to V for all V (i.e. it is covariant) @SuppressWarnings({"unchecked", "rawtypes"}) ListenableFuture<V> typedNull = (ListenableFuture) ImmediateSuccessfulFuture.NULL; return typedNull; } return new ImmediateSuccessfulFuture<V>(value); }
/** * Creates a {@code ListenableFuture} which has its value set immediately upon construction. The * getters just return the value. This {@code Future} can't be canceled or timed out and its * {@code isDone()} method always returns {@code true}. */ public static <V> ListenableFuture<V> immediateFuture(@NullableDecl V value) { if (value == null) { // This cast is safe because null is assignable to V for all V (i.e. it is covariant) @SuppressWarnings({"unchecked", "rawtypes"}) ListenableFuture<V> typedNull = (ListenableFuture) ImmediateSuccessfulFuture.NULL; return typedNull; } return new ImmediateSuccessfulFuture<V>(value); }